home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / role / AMScen_0_9.lha / AMScen / build1.m < prev    next >
Text File  |  1995-01-21  |  77KB  |  3,213 lines

  1. /*
  2.  * Amiga MUD
  3.  *
  4.  * Copyright (c) 1995 by Chris Gray
  5.  */
  6.  
  7. /*
  8.  * build - code to come after the full startup set to set up the commands
  9.  *    which allow simple room-building.
  10.  *    NOTE: most of the code must be 'utility', since we want the rooms,
  11.  *    etc. to be owned by the character issuing the commands.
  12.  */
  13.  
  14. private tp_build1 CreateTable().
  15. use tp_build1
  16.  
  17. define tp_build r_playPen CreateThing(r_indoors).
  18.  
  19. define tp_build p_rPlayPen CreateBoolProp().
  20. define tp_build1 p_pActiveDir CreateIntProp().
  21. define tp_build1 p_pActiveCode CreateStringProp().
  22. define tp_build1 p_pActiveState CreateIntProp().
  23. define tp_build1 p_pSaveState CreateIntProp().
  24.     define tp_build1 st_noState     0.
  25.     define tp_build1 st_preCondition    1.
  26.     define tp_build1 st_condition    2.
  27.     define tp_build1 st_then        3.
  28.     define tp_build1 st_else        4.
  29.     define tp_build1 st_descTrue    5.
  30.     define tp_build1 st_descFalse    6.
  31.     define tp_build1 st_descResult    7.
  32.     define tp_build1 st_condition2    8.
  33.     define tp_build1 st_then2        9.
  34.     define tp_build1 st_else2        10.
  35.     define tp_build1 STRING_FIRST    20.
  36.     define tp_build1 STRING_OTHER    40.
  37. define tp_build1 p_pHadCondition CreateBoolProp().
  38. define tp_build1 p_pCodeKind CreateIntProp().
  39.     define tp_build1 ck_roomChecker    0.
  40.     define tp_build1 ck_objectChecker    1.
  41.     define tp_build1 ck_roomDesc    2.
  42.     define tp_build1 ck_objectDesc    3.
  43.     define tp_build1 ck_roomVoid    4.
  44.     define tp_build1 ck_objectVoid    5.
  45. define tp_build1 p_pNewName CreateStringProp().
  46. define tp_build1 p_pActiveThing CreateThingProp().
  47. define tp_build1 p_pActiveTable CreateTableProp().
  48. define tp_build1 p_pActiveVerb CreateStringProp().
  49.  
  50. define tp_build1 wh_character     0.
  51. define tp_build1 wh_room     1.
  52. define tp_build1 wh_object     2.
  53.  
  54. CharacterThing(SysAdmin)@p_pBuilder := true.
  55.  
  56. define tp_build1 g_build CreateGrammar().
  57.  
  58. define tp_build1 proc utility v_build()bool:
  59.     string s;
  60.  
  61.     if Me()@p_pBuilder or Here()@p_rPlayPen then
  62.     s := GetTail();
  63.     if s = "" then
  64.         Print("Missing build command - "
  65.           "see builder's library for details.\n");
  66.         false
  67.     else
  68.         Parse(g_build, s) ~= 0
  69.     fi
  70.     else
  71.     Print("Sorry, you have not been enabled for building.\n");
  72.     false
  73.     fi
  74. corp;
  75.  
  76. VerbTail(G, "@", v_build).
  77. Synonym(G, "@", "b").
  78. Synonym(G, "@", "build").
  79. Synonym(G, "@", "construct").
  80.  
  81. define tp_build proc utility checkTable(string tableName)table:
  82.     table theTable;
  83.  
  84.     theTable := LookupTable(nil, tableName);
  85.     if theTable = nil then
  86.     if IsDefined(nil, tableName) then
  87.         Print("\"" + tableName + "\" is not a table.\n");
  88.     else
  89.         Print("\"" + tableName + "\" is not defined.\n");
  90.     fi;
  91.     nil
  92.     else
  93.     theTable
  94.     fi
  95. corp;
  96.  
  97. define tp_build1 proc utility findTable(string tableName; bool readOnly)table:
  98.     table theTable;
  99.  
  100.     if tableName = "public" then
  101.     if Me()@p_pBuilder or readOnly then
  102.         PublicTable()
  103.     else
  104.         Print("Only true builders can change the public symbol table.\n");
  105.         nil
  106.     fi
  107.     elif tableName = "private" then
  108.     PrivateTable()
  109.     else
  110.     checkTable(tableName)
  111.     fi
  112. corp;
  113.  
  114. /*****************************************************************************\
  115. *                                          *
  116. *        code to implement a 'compiler' for actions              *
  117. *                                          *
  118. \*****************************************************************************/
  119.  
  120. define tp_build1 proc utility error(string str)void:
  121.  
  122.     Print("*** " + str + ".\n");
  123.     if not Me()@p_pHidden then
  124.     OPrint(FormatName(Me()@p_pName) +
  125.         " abruptly stops gesturing and grimaces.\n");
  126.     fi;
  127. corp;
  128.  
  129. define tp_build1 proc utility stringError(string w, str)void:
  130.     error("'" + w + "' " + str);
  131. corp;
  132.  
  133. define tp_build1 proc utility notCounter(string w)void:
  134.     stringError(w, "is not a defined counter");
  135. corp;
  136.  
  137. define tp_build1 proc utility notFlag(string w)void:
  138.     stringError(w, "is not a defined flag");
  139. corp;
  140.  
  141. define tp_build1 proc utility notString(string w)void:
  142.     stringError(w, "is not a defined string");
  143. corp;
  144.  
  145. define tp_build1 proc utility notObject(string w)void:
  146.     stringError(w, "is not an object-symbol");
  147. corp;
  148.  
  149. define tp_build1 proc utility notRoom(string w)void:
  150.     stringError(w, "isnot a room-symbol");
  151. corp;
  152.  
  153. define tp_build1 proc utility checkWord(string w, nameTail1, nameTail2;
  154.                     int kind)bool:
  155.  
  156.     w == "character" + nameTail1 or w == "character" + nameTail2 or
  157.     w == "room" + nameTail1 or w == "room" + nameTail2 or
  158.     (kind = ck_objectChecker or kind = ck_objectDesc or
  159.     kind = ck_objectVoid) and
  160.     (w == "object" + nameTail1 or w == "object" + nameTail2)
  161. corp;
  162.  
  163. define tp_build1 proc utility pickWhich(string w, nameTail1, nameTail2)int:
  164.  
  165.     if w == "character" + nameTail1 or w == "character" + nameTail2 then
  166.     wh_character
  167.     elif w == "room" + nameTail1 or w == "room" + nameTail2 then
  168.     wh_room
  169.     else
  170.     /* do NOT check for "object" + nameTail */
  171.     wh_object
  172.     fi
  173. corp;
  174.  
  175. define tp_build1 proc utility doWhich(int which)string:
  176.  
  177.     case which
  178.     incase wh_character:
  179.     "Me()"
  180.     incase wh_room:
  181.     "Here()"
  182.     incase wh_object:
  183.     "It()"
  184.     default:
  185.     "xxx"
  186.     esac
  187. corp;
  188.  
  189. define tp_build1 proc utility doWhich2(int which)string:
  190.  
  191.     case which
  192.     incase wh_character:
  193.     "p_pCarrying"
  194.     incase wh_room:
  195.     "p_rContents"
  196.     incase wh_object:
  197.     "p_oContents"
  198.     default:
  199.     "xxx"
  200.     esac
  201. corp;
  202.  
  203. define tp_build1 proc utility roomToObject(int kind)void:
  204.  
  205.     Me()@p_pCodeKind :=
  206.     case kind
  207.     incase ck_roomChecker:
  208.         ck_objectChecker
  209.     incase ck_roomDesc:
  210.         ck_objectDesc
  211.     incase ck_roomVoid:
  212.         ck_objectVoid
  213.     default:
  214.         kind
  215.     esac;
  216. corp;
  217.  
  218. define tp_build1 proc utility checkStringSpecials(string s; int kind;
  219.                           string code)string:
  220.     int which, len, pos;
  221.     string w;
  222.     property string theString;
  223.     property int theCounter;
  224.  
  225.     if SubString(s, 0, 1) = "@" then
  226.     SetTail(SubString(s, 1, Length(s) - 1));
  227.     w := GetWord();
  228.     if checkWord(w, "string", "", kind) then
  229.         which := pickWhich(w, "string", "");
  230.         w := GetWord();
  231.         if w = "" then
  232.         error("Missing string-symbol");
  233.         else
  234.         theString := LookupString(nil, w);
  235.         if theString = nil then
  236.             notString(w);
  237.         else
  238.             code := code + "\"+" + doWhich(which) + "@" + w + "+\"";
  239.         fi;
  240.         fi;
  241.     elif checkWord(w, "counter", "", kind) then
  242.         which := pickWhich(w, "counter", "");
  243.         w := GetWord();
  244.         if w = "" then
  245.         error("Missing counter-symbol");
  246.         else
  247.         theCounter := LookupCounter(nil, w);
  248.         if theCounter = nil then
  249.             notCounter(w);
  250.         else
  251.             code := code + "\"+IntToString(" + doWhich(which) + "@" +
  252.             w + ")+\"";
  253.         fi;
  254.         fi;
  255.     elif checkWord(w, "name", "", kind) then
  256.         case pickWhich(w, "name", "")
  257.         incase wh_character:
  258.         code := code + "\"+FormatName(Me()@p_pName)+\"";
  259.         incase wh_room:
  260.         code := code + "\"+Here()@p_rName+\"";
  261.         incase wh_object:
  262.         code := code + "\"+FormatName(It()@p_oName)+\"";
  263.         esac;
  264.     else
  265.         stringError(w, "is not a known text escape");
  266.     fi;
  267.     else
  268.     len := Length(s);
  269.     w := "";
  270.     while
  271.         pos := Index(s, "\"");
  272.         pos >= 0
  273.     do
  274.         w := w + SubString(s, 0, pos) + "\\\"";
  275.         len := len - pos - 1;
  276.         s := SubString(s, pos + 1, len);
  277.     od;
  278.     code := code + w + s;
  279.     fi;
  280.     code
  281. corp;
  282.  
  283. define tp_build1 proc utility continuePrompt(int state, kind)void:
  284.  
  285.     case state
  286.     incase st_preCondition:
  287.     if kind = ck_roomVoid or kind = ck_objectVoid then
  288.         Print("Continue entering actions:\n");
  289.         ignore SetPrompt("* actions> ");
  290.     else
  291.         Print("Continue entering pre-condition actions:\n");
  292.         ignore SetPrompt("* pre-condition actions> ");
  293.     fi;
  294.     incase st_then:
  295.     incase st_then2:
  296.     Print("Continue entering the true actions:\n");
  297.     ignore SetPrompt("* true actions> ");
  298.     incase st_else:
  299.     incase st_else2:
  300.     Print("Continue entering the false actions:\n");
  301.     ignore SetPrompt("* false actions> ");
  302.     esac;
  303. corp;
  304.  
  305. define tp_build1 proc utility conditionPrompt()void:
  306.     Print("Now enter the conditions for the test:\n");
  307.     ignore SetPrompt("* condition> ");
  308. corp;
  309.  
  310. define tp_build1 proc utility truePrompt()void:
  311.     Print("Now enter the actions to do if condition is true:\n");
  312.     ignore SetPrompt("* true actions> ");
  313. corp;
  314.  
  315. define tp_build1 proc utility falsePrompt()void:
  316.     Print("Now enter the actions to do if condition is false:\n");
  317.     ignore SetPrompt("* false actions> ");
  318. corp;
  319.  
  320. define tp_build1 proc utility compileCode(string code)void:
  321.     action a;
  322.     thing me;
  323.     string characterName;
  324.  
  325.     me := Me();
  326.     characterName := FormatName(me@p_pName);
  327.     a := StringToAction(code);
  328.     if a = nil then
  329.     error("Errors in action - not defined");
  330.     else
  331.     if DefineAction(me@p_pActiveTable, me@p_pNewName, a) then
  332.         Print("Action '" + me@p_pNewName + "' defined.\n");
  333.     fi;
  334.     if not me@p_pHidden then
  335.         OPrint(characterName + " finishes gesturing.\n");
  336.     fi;
  337.     fi;
  338. corp;
  339.  
  340. define tp_build1 proc utility bv_actionLineHandler(string s)void:
  341.     thing me, theThing, theRoom;
  342.     int state, kind, value, which;
  343.     string code, w, w2, w3, errMess;
  344.     action a;
  345.     property bool theFlag;
  346.     property int theCounter;
  347.     property string theString;
  348.     bool ending, tf, isNegative;
  349.  
  350.     ending := false;
  351.     me := Me();
  352.     state := me@p_pActiveState;
  353.     code := me@p_pActiveCode;
  354.     kind := me@p_pCodeKind;
  355.     if s = "." then
  356.     case state
  357.     incase st_preCondition:
  358.         /* end of pre-condition actions */
  359.         if kind = ck_roomVoid or kind = ck_objectVoid then
  360.         compileCode(code);
  361.         ending := true;
  362.         else
  363.         state := st_condition;
  364.         conditionPrompt();
  365.         fi;
  366.     incase st_condition:
  367.         /* end of condition */
  368.         if not me@p_pHadCondition then
  369.         if kind = ck_roomDesc or kind = ck_objectDesc then
  370.             if code ~= "" then
  371.             code := code + ";";
  372.             fi;
  373.             code := code + "\"";
  374.             state := st_descResult + STRING_FIRST;
  375.             Print("Now enter the result description:\n");
  376.             ignore SetPrompt("* description result> ");
  377.         else
  378.             if kind = ck_objectChecker then
  379.             code := code + ";succeed";
  380.             else
  381.             code := code + ";continue";
  382.             fi;
  383.             compileCode(code);
  384.             ending := true;
  385.         fi;
  386.         else
  387.         code := code + " then ";
  388.         state := st_then;
  389.         truePrompt();
  390.         fi;
  391.     incase st_then:
  392.         /* end of 'then' actions */
  393.         if kind = ck_roomDesc or kind = ck_objectDesc then
  394.         code := code + "\"";
  395.         state := st_descTrue + STRING_FIRST;
  396.         Print("Now enter the true description result:\n");
  397.         ignore SetPrompt("* true description result> ");
  398.         else
  399.         if kind = ck_objectChecker then
  400.             code := code + "succeed else ";
  401.         else
  402.             code := code + "continue else ";
  403.         fi;
  404.         state := st_else;
  405.         falsePrompt();
  406.         fi;
  407.     incase st_else:
  408.         /* end of 'else' actions */
  409.         if kind = ck_roomDesc or kind = ck_objectDesc then
  410.         code := code + "\"";
  411.         state := st_descFalse + STRING_FIRST;
  412.         Print("Now enter the false description result:\n");
  413.         ignore SetPrompt("* false description result> ");
  414.         else
  415.         code := code + "fail fi";
  416.         compileCode(code);
  417.         ending := true;
  418.         fi;
  419.     incase st_condition2:
  420.         if not me@p_pHadCondition then
  421.         error("Condition is required on 'if'");
  422.         ending := true;
  423.         else
  424.         code := code + " then ";
  425.         state := st_then2;
  426.         truePrompt();
  427.         fi;
  428.     incase st_then2:
  429.         code := code + "else ";
  430.         state := st_else2;
  431.         falsePrompt();
  432.     incase st_else2:
  433.         code := code + "fi;";
  434.         state := me@p_pSaveState;
  435.         me -- p_pSaveState;
  436.         continuePrompt(state, kind);
  437.     default:
  438.         /* end of a string */
  439.         if state >= STRING_OTHER then
  440.         state := state - STRING_OTHER;
  441.         else
  442.         state := state - STRING_FIRST;
  443.         fi;
  444.         case state
  445.         incase st_preCondition:
  446.         incase st_then:
  447.         incase st_else:
  448.         incase st_then2:
  449.         incase st_else2:
  450.         code := code + "\\n\");";
  451.         continuePrompt(state, kind);
  452.         incase st_descTrue:
  453.         /* end of 'then' description result */
  454.         code := code + "\" else ";
  455.         state := st_else;
  456.         falsePrompt();
  457.         incase st_descFalse:
  458.         /* end of 'else' description result */
  459.         code := code + "\" fi";
  460.         compileCode(code);
  461.         ending := true;
  462.         incase st_descResult:
  463.         /* end of the description result string */
  464.         code := code + "\"";
  465.         compileCode(code);
  466.         ending := true;
  467.         esac;
  468.     esac;
  469.     else
  470.     errMess := "Missing flag/counter-symbol";
  471.     SetTail(s);
  472.     w := GetWord();
  473.     if state = st_condition or state = st_condition2 then
  474.         /* handling conditions */
  475.         if me@p_pHadCondition then
  476.         code := code + " and ";
  477.         else
  478.         code := code + "if ";
  479.         me@p_pHadCondition := true;
  480.         fi;
  481.         if w == "not" then
  482.         code := code + "not ";
  483.         w := GetWord();
  484.         fi;
  485.         if w == "fail" then
  486.         code := code + "false";
  487.         elif checkWord(w, "flag", "", kind) then
  488.         which := pickWhich(w, "flag", "");
  489.         w := GetWord();
  490.         if w = "" then
  491.             error(errMess);
  492.             ending := true;
  493.         else
  494.             theFlag := LookupFlag(nil, w);
  495.             if theFlag ~= nil then
  496.             code := code + doWhich(which) + "@" + w;
  497.             else
  498.             notFlag(w);
  499.             ending := true;
  500.             fi;
  501.         fi;
  502.         elif checkWord(w, "counter", "", kind) then
  503.         which := pickWhich(w, "counter", "");
  504.         w := GetWord();
  505.         if w = "" then
  506.             error(errMess);
  507.             ending := true;
  508.         else
  509.             theCounter := LookupCounter(nil, w);
  510.             if theCounter ~= nil then
  511.             w2 := GetWord();
  512.             isNegative := false;
  513.             if SubString(w2, 0, 1) = "-" then
  514.                 isNegative := true;
  515.                 w2 := SubString(w2, 1, Length(w2) - 1);
  516.             elif SubString(w2, 0, 1) = "+" then
  517.                 w2 := SubString(w2, 1, Length(w2) - 1);
  518.             fi;
  519.             value := StringToPosInt(w2);
  520.             if value < 0 then
  521.                 error("Missing or invalid counter value");
  522.                 ending := true;
  523.             else
  524.                 if isNegative then
  525.                 value := -value;
  526.                 fi;
  527.                 code := code + doWhich(which) + "@" + w + "=" +
  528.                 IntToString(value);
  529.             fi;
  530.             else
  531.             notCounter(w);
  532.             ending := true;
  533.             fi;
  534.         fi;
  535.         elif checkWord(w, "hasspecific", "", kind) then
  536.         which := pickWhich(w, "hasspecific", "");
  537.         w := GetWord();
  538.         if w = "" then
  539.             error("Missing object-symbol");
  540.             ending := true;
  541.         else
  542.             theThing := LookupThing(nil, w);
  543.             if theThing ~= nil and theThing@p_oName ~= "" then
  544.             code := code + "FindElement(" + doWhich(which) + "@" +
  545.                 doWhich2(which) + "," + w + ")~=-1";
  546.             else
  547.             notObject(w);
  548.             ending := true;
  549.             fi;
  550.         fi;
  551.         elif checkWord(w, "haschild", "", kind) then
  552.         which := pickWhich(w, "haschild", "");
  553.         w := GetWord();
  554.         if w = "" then
  555.             error("Missing object child form");
  556.             ending := true;
  557.         else
  558.             theThing := LookupThing(nil, w);
  559.             if theThing ~= nil and theThing@p_oName ~= "" then
  560.             code := code + "FindChildOnList(" + doWhich(which) +
  561.                 "@" + doWhich2(which) + "," + w + ")";
  562.             else
  563.             notObject(w);
  564.             ending := true;
  565.             fi;
  566.         fi;
  567.         elif checkWord(w, "hasname", "", kind) then
  568.         which := pickWhich(w, "hasname", "");
  569.         w := GetWord();
  570.         if w = "" then
  571.             error("Missing object name form");
  572.             ending := true;
  573.         else
  574.             code := code + "FindName(" + doWhich(which) + "@" +
  575.                 doWhich2(which) + ",p_oName,\"" + Strip(w) +
  576.                 "\")~=fail";
  577.         fi;
  578.         elif checkWord(w, "hasflag", "", kind) then
  579.         which := pickWhich(w, "hasflag", "");
  580.         w := GetWord();
  581.         if w = "" then
  582.             error(errMess);
  583.             ending := true;
  584.         else
  585.             theFlag := LookupFlag(nil, w);
  586.             if theFlag = nil then
  587.             notFlag(w);
  588.             ending := true;
  589.             else
  590.             code := code + "FindFlagOnList(" + doWhich(which) +
  591.                 "@" + doWhich2(which) + "," + w + ")";
  592.             fi;
  593.         fi;
  594.         elif w == "random" then
  595.         w := GetWord();
  596.         value := StringToPosInt(w);
  597.         if value <= 1 then
  598.             error("Missing or invalid random range");
  599.             ending := true;
  600.         else
  601.             code := code + "Random(" + w + ")=0";
  602.         fi;
  603.         else
  604.         stringError(w, "is not a known condition");
  605.         ending := true;
  606.         fi;
  607.     elif state >= STRING_OTHER then
  608.         /* getting a string - subsequent hunk */
  609.         if s ~= "" then
  610.         code := checkStringSpecials(s, kind, code + " ");
  611.         fi;
  612.     elif state >= STRING_FIRST then
  613.         /* getting a string - first hunk */
  614.         code := checkStringSpecials(s, kind, code);
  615.         state := state - STRING_FIRST + STRING_OTHER;
  616.     else
  617.         /* handling statements */
  618.         if checkWord(w, "setflag", "clearflag", kind) then
  619.         which := pickWhich(w, "setflag", "clearflag");
  620.         tf := w == "charactersetflag" or w == "roomsetflag" or
  621.             w == "objectsetflag";
  622.         w := GetWord();
  623.         if w = "" then
  624.             error(errMess);
  625.             ending := true;
  626.         else
  627.             theFlag := LookupFlag(nil, w);
  628.             if theFlag = nil then
  629.             notFlag(w);
  630.             ending := true;
  631.             else
  632.             if tf then
  633.                 code := code + doWhich(which) + "@" + w +
  634.                 ":=true;";
  635.             else
  636.                 code := code + doWhich(which) + "--" + w + ";";
  637.             fi;
  638.             fi;
  639.         fi;
  640.         elif checkWord(w, "inccounter", "deccounter", kind) then
  641.         which := pickWhich(w, "inccounter", "deccounter");
  642.         tf := w == "characterinccounter" or w == "roominccounter" or
  643.             w == "objectinccounter";
  644.         w := GetWord();
  645.         if w = "" then
  646.             error(errMess);
  647.             ending := true;
  648.         else
  649.             theCounter := LookupCounter(nil, w);
  650.             if theCounter = nil then
  651.             notCounter(w);
  652.             ending := true;
  653.             else
  654.             w2 := GetWord();
  655.             if w2 ~= "" then
  656.                 value := StringToPosInt(w2);
  657.                 if value < 0 then
  658.                 error("Invalid inc/dec value");
  659.                 ending := true;
  660.                 fi;
  661.             else
  662.                 value := 1;
  663.             fi;
  664.             w2 := doWhich(which);
  665.             code := code + w2 + "@" + w + ":=" + w2 + "@" + w +
  666.                 if tf then "+" else "-" fi +
  667.                 IntToString(value) + ";";
  668.             fi;
  669.         fi;
  670.         elif checkWord(w, "setcounter", "", kind) then
  671.         which := pickWhich(w, "setcounter", "");
  672.         w := GetWord();
  673.         if w = "" then
  674.             error(errMess);
  675.             ending := true;
  676.         else
  677.             theCounter := LookupCounter(nil, w);
  678.             if theCounter ~= nil then
  679.             w2 := GetWord();
  680.             isNegative := false;
  681.             if SubString(w2, 0, 1) = "-" then
  682.                 isNegative := true;
  683.                 w2 := SubString(w2, 1, Length(w2) - 1);
  684.             elif SubString(w2, 0, 1) = "+" then
  685.                 w2 := SubString(w2, 1, Length(w2) - 1);
  686.             fi;
  687.             value := StringToPosInt(w2);
  688.             if value < 0 then
  689.                 error("Missing or invalid counter value");
  690.                 ending := true;
  691.             else
  692.                 if value = 0 then
  693.                 code := code + doWhich(which) + "--" + w + ";";
  694.                 else
  695.                 if isNegative then
  696.                     value := -value;
  697.                 fi;
  698.                 code := code + doWhich(which) + "@" +
  699.                     w + ":=" + IntToString(value) + ";";
  700.                 fi;
  701.             fi;
  702.             else
  703.             notCounter(w);
  704.             ending := true;
  705.             fi;
  706.         fi;
  707.         elif checkWord(w, "setstring", "", kind) then
  708.         which := pickWhich(w, "setstring", "");
  709.         w := GetWord();
  710.         if w = "" then
  711.             error("Missing string-symbol");
  712.             ending := true;
  713.         else
  714.             theString := LookupString(nil, w);
  715.             if theString = nil then
  716.             notString(w);
  717.             ending := true;
  718.             elif w = "p_pName" or w = "p_rName" or w = "p_oName" then
  719.             error("Sorry - you can't modify that string");
  720.             ending := true;
  721.             else
  722.             w3 := GetWord();
  723.             if w3 = "" then
  724.                 error("Missing string identifier");
  725.                 ending := true;
  726.             else
  727.                 if w3 == "date" or w3 == "time" then
  728.                 w2 := "Date()";
  729.                 elif w3 == "charactername" then
  730.                 w2 := "FormatName(Me()@p_pName)";
  731.                 elif w3 == "roomname" then
  732.                 w2 := "Here()@p_rName";
  733.                 elif w3 == "objectname" and
  734.                 (kind = ck_objectChecker or
  735.                  kind = ck_objectDesc or
  736.                  kind = ck_objectVoid)
  737.                 then
  738.                 w2 := "FormatName(It()@p_oName)";
  739.                 else
  740.                 stringError(w3,
  741.                     "is not a known string identifier");
  742.                 ending := true;
  743.                 w2 := "\"\"";
  744.                 fi;
  745.                 code := code + doWhich(which) + "@" + w + ":=" +
  746.                 w2 + ";";
  747.             fi;
  748.             fi;
  749.         fi;
  750.         elif checkWord(w, "clearstring", "", kind) then
  751.         which := pickWhich(w, "clearstring", "");
  752.         w := GetWord();
  753.         if w = "" then
  754.             error("Missing string-symbol");
  755.             ending := true;
  756.         else
  757.             theString := LookupString(nil, w);
  758.             if theString ~= nil then
  759.             code := code + doWhich(which) + "--" + w + ";";
  760.             else
  761.             notString(w);
  762.             ending := true;
  763.             fi;
  764.         fi;
  765.         elif w == "clonehere" or w == "cloneat" then
  766.         if not Me()@p_pBuilder then
  767.             error("Sorry, only true builders can clone things");
  768.             ending := true;
  769.         elif w = "cloneat" then
  770.             w2 := GetWord();
  771.             if w2 = "" then
  772.             error("Missing room-symbol");
  773.             ending := true;
  774.             else
  775.             theRoom := LookupThing(nil, w2);
  776.             if theRoom = nil or theRoom@p_rName = "" then
  777.                 notRoom(w2);
  778.                 ending := true;
  779.             fi;
  780.             fi;
  781.         fi;
  782.         w3 := GetWord();
  783.         if ending or w3 = "" then
  784.             if not ending then
  785.             error("Missing object-symbol");
  786.             ending := true;
  787.             fi;
  788.         else
  789.             theThing := LookupThing(nil, w3);
  790.             if theThing ~= nil and theThing@p_oName ~= "" then
  791.             code := code + "SetIt(CreateThing(" + w3 +
  792.                 "));AddTail(" +
  793.                 if w == "clonehere" then "Here()" else w2 fi +
  794.                 "@p_rContents,It());" +
  795.                 "SetThingStatus(It(),ts_public);" +
  796.                 "GiveThing(It(),Character(\"SysAdmin\"));" +
  797.                 "It()@p_oCarryer:=Me();" +
  798.                 "It()@p_oCreator:=Me();";
  799.             roomToObject(kind);
  800.             else
  801.             notObject(w3);
  802.             ending := true;
  803.             fi;
  804.         fi;
  805.         elif w == "destruct" and
  806.         (kind = ck_objectChecker or kind = ck_objectDesc or
  807.          kind = ck_objectVoid)
  808.         then
  809.         code := code + "ClearThing(It());" +
  810.             "DelElement(Me()@p_pCarrying,It());";
  811.         elif w == "drop" and
  812.         (kind = ck_objectChecker or kind = ck_objectDesc or
  813.          kind = ck_objectVoid)
  814.         then
  815.         code := code + "ignore DoDrop(Here(),Me(),It());";
  816.         elif w == "dropto" and
  817.         (kind = ck_objectChecker or kind = ck_objectDesc or
  818.          kind = ck_objectVoid)
  819.         then
  820.         w := GetWord();
  821.         if w = "" then
  822.             error("Missing room-symbol");
  823.             ending := true;
  824.         else
  825.             theRoom := LookupThing(nil, w);
  826.             if theRoom ~= nil and theRoom@p_rName ~= "" then
  827.             code := code + "ignore DoDrop(" + w + ",Me(),It());";
  828.             else
  829.             notRoom(w);
  830.             ending := true;
  831.             fi;
  832.         fi;
  833.         elif w == "setit" then
  834.         w := GetWord();
  835.         if w = "" then
  836.             error("Missing object kind");
  837.             ending := true;
  838.         else
  839.             w2 := GetWord();
  840.             if w2 = "" then
  841.             error("Missing object-symbol/flag-symbol/string");
  842.             ending := true;
  843.             else
  844.             if w == "specific" then
  845.                 theThing := LookupThing(nil, w2);
  846.                 if theThing ~= nil and theThing@p_oName ~= "" then
  847.                 code := code + "SetIt(" + w2 + ");";
  848.                 else
  849.                 notObject(w2);
  850.                 ending := true;
  851.                 fi;
  852.             elif checkWord(w, "child", "", kind) then
  853.                 theThing := LookupThing(nil, w2);
  854.                 if theThing ~= nil and theThing@p_oName ~= "" then
  855.                 which := pickWhich(w, "child", "");
  856.                 code := code + "ignore FindChildOnList(" +
  857.                     doWhich(which) + "@" + doWhich2(which) +
  858.                     "," + w2 + ");SetIt(FindResult());";
  859.                 else
  860.                 notObject(w2);
  861.                 ending := true;
  862.                 fi;
  863.             elif checkWord(w, "flag", "", kind) then
  864.                 theFlag := LookupFlag(nil, w2);
  865.                 if theFlag ~= nil then
  866.                 which := pickWhich(w, "flag", "");
  867.                 code := code + "ignore FindFlagOnList(" +
  868.                     doWhich(which) + "@" + doWhich2(which) +
  869.                     "," + w2 + ");SetIt(FindResult());";
  870.                 else
  871.                 notFlag(w);
  872.                 ending := true;
  873.                 fi;
  874.             elif checkWord(w, "name", "", kind) then
  875.                 which := pickWhich(w, "name", "");
  876.                 code := code + "ignore FindName(" +
  877.                 doWhich(which) + "@" + doWhich2(which) +
  878.                 ",p_oName,\"" + Strip(w2) +
  879.                 "\");SetIt(FindResult());";
  880.             else
  881.                 stringError(w, "is not a known object kind");
  882.                 ending := true;
  883.             fi;
  884.             roomToObject(kind);
  885.             fi;
  886.         fi;
  887.         elif w == "saycharacter" then
  888.         code := code + "Print(\"";
  889.         state := state + STRING_FIRST;
  890.         Print("Enter the text to be shown to the character:\n");
  891.         ignore SetPrompt("* character text> ");
  892.         elif w == "sayothers" then
  893.         code := code + "OPrint(\"";
  894.         state := state + STRING_FIRST;
  895.         Print("Enter the text to be shown to others:\n");
  896.         ignore SetPrompt("* others text> ");
  897.         elif w == "if" then
  898.         if me@p_pSaveState ~= st_noState then
  899.             error("Sorry, you cannot nest 'if's");
  900.             ending := true;
  901.         else
  902.             me@p_pSaveState := state;
  903.             me@p_pHadCondition := false;
  904.             state := st_condition2;
  905.             Print("Enter the condition for the if:\n");
  906.             ignore SetPrompt("* condition> ");
  907.         fi;
  908.         else
  909.         stringError(w, "is not a known action");
  910.         ending := true;
  911.         fi;
  912.     fi;
  913.     fi;
  914.     if ending then
  915.     me -- p_pActiveCode;
  916.     me -- p_pActiveState;
  917.     me -- p_pSaveState;
  918.     me -- p_pHadCondition;
  919.     me -- p_pCodeKind;
  920.     me -- p_pActiveDir;
  921.     me -- p_pNewName;
  922.     me -- p_pActiveTable;
  923.     GetCheckedEnd();
  924.     else
  925.     me@p_pActiveCode := code;
  926.     me@p_pActiveState := state;
  927.     fi;
  928. corp;
  929.  
  930. define tp_build1 proc utility getAction(table theTable; string name)bool:
  931.     thing me;
  932.  
  933.     me := Me();
  934.     me@p_pActiveTable := theTable;
  935.     me@p_pNewName := name;
  936.     me@p_pActiveCode := "";
  937.     me@p_pActiveState := st_preCondition;
  938.     me@p_pHadCondition := false;
  939.     if not me@p_pHidden then
  940.     OPrint(FormatName(me@p_pName) + " starts gesturing arcanely.\n");
  941.     fi;
  942.     if me@p_pCodeKind = ck_roomVoid or me@p_pCodeKind = ck_objectVoid then
  943.     Print("Enter the actions:\n");
  944.     GetCheckedDescription("actions> ", bv_actionLineHandler)
  945.     else
  946.     Print("Enter the pre-condition actions:\n");
  947.     GetCheckedDescription("pre-condition actions> ", bv_actionLineHandler)
  948.     fi
  949. corp;
  950.  
  951. /*****************************************************************************\
  952. *                                          *
  953. *        now the actual building subcommands                  *
  954. *                                          *
  955. \*****************************************************************************/
  956.  
  957. /*****************************************************************************\
  958. *                                          *
  959. *        first, some generic building subcommands              *
  960. *                                          *
  961. \*****************************************************************************/
  962.  
  963. define tp_build1 proc utility checkBuilder()bool:
  964.  
  965.     /* This check is used in @table, @use and @unuse. The most important
  966.        is in @use, since otherwise a character in the PlayPen could
  967.        "@use t_base", and then write actions which increased his money,
  968.        etc.! */
  969.     if Me()@p_pBuilder then
  970.     true
  971.     else
  972.     Print("Sorry, only true builders can use that command.\n");
  973.     false
  974.     fi
  975. corp;
  976.  
  977. define tp_build1 proc utility bv_showtable(string tableName)bool:
  978.     table theTable;
  979.  
  980.     if tableName = "" then
  981.     Print("Use is: @showtable <table>\n");
  982.     false
  983.     else
  984.     theTable := findTable(tableName, true);
  985.     if theTable = nil then
  986.         false
  987.     else
  988.         ShowTable(theTable);
  989.         true
  990.     fi
  991.     fi
  992. corp;
  993.  
  994. Verb1(g_build, "showtable", 0, bv_showtable).
  995.  
  996. define tp_build1 proc utility bv_describesymbol()bool:
  997.     string tableName, what;
  998.     table theTable;
  999.  
  1000.     tableName := GetWord();
  1001.     what := GetWord();
  1002.     if tableName = "" or what = "" or GetWord() ~= "" then
  1003.     Print("Use is: @describesymbol <table> <symbol>\n");
  1004.     false
  1005.     else
  1006.     theTable := findTable(tableName, true);
  1007.     if theTable = nil then
  1008.         false
  1009.     else
  1010.         DescribeSymbol(theTable, Strip(what));
  1011.         true
  1012.     fi
  1013.     fi
  1014. corp;
  1015.  
  1016. VerbTail(g_build, "describesymbol", bv_describesymbol).
  1017. Synonym(g_build, "describesymbol", "describe").
  1018. Synonym(g_build, "describesymbol", "d").
  1019.  
  1020. define tp_build1 proc utility bv_deletesymbol()bool:
  1021.     string tableName, what;
  1022.     table theTable;
  1023.  
  1024.     tableName := GetWord();
  1025.     what := GetWord();
  1026.     if tableName = "" or what = "" or GetWord() ~= "" then
  1027.     Print("Use is: @deletesymbol <table> <symbol>\n");
  1028.     false
  1029.     else
  1030.     theTable := findTable(tableName, false);
  1031.     if theTable = nil then
  1032.         false
  1033.     else
  1034.         ignore DeleteSymbol(theTable, Strip(what));
  1035.         true
  1036.     fi
  1037.     fi
  1038. corp;
  1039.  
  1040. VerbTail(g_build, "deletesymbol", bv_deletesymbol).
  1041. Synonym(g_build, "deletesymbol", "delete").
  1042.  
  1043. define tp_build1 proc utility bv_movesymbol()bool:
  1044.     string fromTableName, toTableName, what;
  1045.     table fromTable, toTable;
  1046.  
  1047.     fromTableName := GetWord();
  1048.     toTableName := GetWord();
  1049.     what := GetWord();
  1050.     if fromTableName = "" or toTableName = "" or what = "" or GetWord() ~= ""
  1051.     then
  1052.     Print("Use is: @movesymbol <from-table> <to-table> <symbol>\n");
  1053.     false
  1054.     else
  1055.     fromTable := findTable(fromTableName, false);
  1056.     if fromTable = nil then
  1057.         false
  1058.     else
  1059.         toTable := findTable(toTableName, false);
  1060.         if toTable = nil then
  1061.         false
  1062.         else
  1063.         ignore MoveSymbol(fromTable, toTable, Strip(what));
  1064.         true
  1065.         fi
  1066.     fi
  1067.     fi
  1068. corp;
  1069.  
  1070. VerbTail(g_build, "movesymbol", bv_movesymbol).
  1071. Synonym(g_build, "movesymbol", "move").
  1072.  
  1073. define tp_build1 proc utility bv_renamesymbol()bool:
  1074.     string tableName, oldName, newName;
  1075.     table theTable;
  1076.  
  1077.     tableName := GetWord();
  1078.     oldName := GetWord();
  1079.     newName := GetWord();
  1080.     if tableName = "" or oldName = "" or newName = "" or GetWord() ~= "" then
  1081.     Print("Use is: @renamesymbol <table> <old-symbol> <new-symbol>\n");
  1082.     false
  1083.     else
  1084.     theTable := findTable(tableName, false);
  1085.     if theTable = nil then
  1086.         false
  1087.     else
  1088.         RenameSymbol(theTable, Strip(oldName), Strip(newName))
  1089.     fi
  1090.     fi
  1091. corp;
  1092.  
  1093. VerbTail(g_build, "renamesymbol", bv_renamesymbol).
  1094. Synonym(g_build, "renamesymbol", "rename").
  1095.  
  1096. define tp_build1 proc utility bv_flag()bool:
  1097.     string tableName, name;
  1098.     table theTable;
  1099.  
  1100.     tableName := GetWord();
  1101.     name := GetWord();
  1102.     if tableName = "" or name = "" or GetWord() ~= "" then
  1103.     Print("Use is: @flag <table> <symbol>\n");
  1104.     false
  1105.     else
  1106.     theTable := findTable(tableName, false);
  1107.     if theTable = nil then
  1108.         false
  1109.     else
  1110.         DefineFlag(theTable, name, CreateBoolProp())
  1111.     fi
  1112.     fi
  1113. corp;
  1114.  
  1115. VerbTail(g_build, "flag", bv_flag).
  1116.  
  1117. define tp_build1 proc utility bv_counter()bool:
  1118.     string tableName, name;
  1119.     table theTable;
  1120.  
  1121.     tableName := GetWord();
  1122.     name := GetWord();
  1123.     if tableName = "" or name = "" or GetWord() ~= "" then
  1124.     Print("Use is: @counter <table> <symbol>\n");
  1125.     false
  1126.     else
  1127.     theTable := findTable(tableName, false);
  1128.     if theTable = nil then
  1129.         false
  1130.     else
  1131.         DefineCounter(theTable, name, CreateIntProp())
  1132.     fi
  1133.     fi
  1134. corp;
  1135.  
  1136. VerbTail(g_build, "counter", bv_counter).
  1137.  
  1138. define tp_build1 proc utility bv_string()bool:
  1139.     string tableName, name;
  1140.     table theTable;
  1141.  
  1142.     tableName := GetWord();
  1143.     name := GetWord();
  1144.     if tableName = "" or name = "" or GetWord() ~= "" then
  1145.     Print("Use is: @string <table> <symbol>\n");
  1146.     false
  1147.     else
  1148.     theTable := findTable(tableName, false);
  1149.     if theTable = nil then
  1150.         false
  1151.     else
  1152.         DefineString(theTable, name, CreateStringProp())
  1153.     fi
  1154.     fi
  1155. corp;
  1156.  
  1157. VerbTail(g_build, "string", bv_string).
  1158.  
  1159. define tp_build1 proc utility bv_table()bool:
  1160.     string tableName, name;
  1161.     table theTable;
  1162.  
  1163.     tableName := GetWord();
  1164.     name := GetWord();
  1165.     if not checkBuilder() then
  1166.     false
  1167.     elif tableName = "" or name = "" or GetWord() ~= "" then
  1168.     Print("Use is: @table <existing-table-name> <new-table-name>\n");
  1169.     false
  1170.     else
  1171.     theTable := findTable(tableName, false);
  1172.     if theTable = nil then
  1173.         false
  1174.     else
  1175.         DefineTable(theTable, name, CreateTable())
  1176.     fi
  1177.     fi
  1178. corp;
  1179.  
  1180. VerbTail(g_build, "table", bv_table).
  1181.  
  1182. define tp_build1 proc utility bv_use(string tableName)bool:
  1183.     table theTable;
  1184.  
  1185.     if not checkBuilder() then
  1186.     false
  1187.     elif tableName = "" then
  1188.     Print("Use is: @use <table>\n");
  1189.     false
  1190.     else
  1191.     theTable := checkTable(tableName);
  1192.     if theTable = nil then
  1193.         false
  1194.     else
  1195.         UseTable(theTable)
  1196.     fi
  1197.     fi
  1198. corp;
  1199.  
  1200. Verb1(g_build, "use", 0, bv_use).
  1201.  
  1202. define tp_build1 proc utility bv_unuse(string tableName)bool:
  1203.     table theTable;
  1204.  
  1205.     if not checkBuilder() then
  1206.     false
  1207.     elif tableName = "" then
  1208.     Print("Use is: @unuse <table>\n");
  1209.     false
  1210.     else
  1211.     theTable := checkTable(tableName);
  1212.     if theTable = nil then
  1213.         false
  1214.     else
  1215.         UnUseTable(theTable)
  1216.     fi
  1217.     fi
  1218. corp;
  1219.  
  1220. Verb1(g_build, "unuse", 0, bv_unuse).
  1221.  
  1222. define tp_build1 proc utility bv_symbolhere()bool:
  1223.     string tableName, what;
  1224.     table theTable;
  1225.  
  1226.     tableName := GetWord();
  1227.     what := GetWord();
  1228.     if tableName = "" or what = "" or GetWord() ~= "" then
  1229.     Print("Use is: @symbolhere <table> <symbol>\n");
  1230.     false
  1231.     else
  1232.     theTable := findTable(tableName, false);
  1233.     if theTable = nil then
  1234.         false
  1235.     else
  1236.         DefineThing(theTable, what, Here())
  1237.     fi
  1238.     fi
  1239. corp;
  1240.  
  1241. VerbTail(g_build, "symbolhere", bv_symbolhere).
  1242.  
  1243. define tp_build proc utility bv_poof(string where)bool:
  1244.     string err;
  1245.     thing room;
  1246.     bool privileged;
  1247.     action a;
  1248.  
  1249.     privileged := Me()@p_pPrivileged;
  1250.     err := "Can only POOF between your own rooms.\n";
  1251.     if where = "" then
  1252.     Print("You must specify where you want to poof to.\n");
  1253.     false
  1254.     elif not Mine(Here()) and not privileged then
  1255.     Print(err);
  1256.     false
  1257.     else
  1258.     room := LookupThing(nil, where);
  1259.     if room = nil or room@p_rName = "" then
  1260.         if IsDefined(nil, where) then
  1261.         Print("Name '" + where + "' is not a room.\n");
  1262.         else
  1263.         Print("Name '" + where + "' is not defined.\n");
  1264.         fi;
  1265.         false
  1266.     elif not Mine(room) and not privileged then
  1267.         Print(err);
  1268.         false
  1269.     elif room = Here() then
  1270.         Print("That's where you are!\n");
  1271.         false
  1272.     else
  1273.         LeaveRoomStuff(room, 0, MOVE_POOF);
  1274.         EnterRoomStuff(room, 0, MOVE_POOF);
  1275.         true
  1276.     fi
  1277.     fi
  1278. corp;
  1279.  
  1280. Verb1(g_build, "poof", 0, bv_poof).
  1281.  
  1282. /* a couple of utilities */
  1283.  
  1284. define tp_build proc utility objNameCheck(string symbol)thing:
  1285.     thing th;
  1286.  
  1287.     th := LookupThing(nil, symbol);
  1288.     if th = nil or th@p_oName = "" then
  1289.     if IsDefined(nil, symbol) then
  1290.         Print("'" + symbol + "' is not an object.\n");
  1291.     else
  1292.         Print("You have no object named '" + symbol + "'.\n");
  1293.     fi;
  1294.     nil
  1295.     else
  1296.     th
  1297.     fi
  1298. corp;
  1299.  
  1300. define tp_build1 proc utility actionNameCheck(string symbol)action:
  1301.     action a;
  1302.  
  1303.     a := LookupAction(nil, symbol);
  1304.     if a = nil then
  1305.     if IsDefined(nil, symbol) then
  1306.         Print("'" + symbol + "' is not an action.\n");
  1307.     else
  1308.         Print("You have no action named '" + symbol + "'.\n");
  1309.     fi;
  1310.     nil
  1311.     else
  1312.     a
  1313.     fi
  1314. corp;
  1315.  
  1316. define tp_build proc utility changeDone(string what)void:
  1317.  
  1318.     if Me()@p_pHidden then
  1319.     OPrint("Someone has " + what + ".\n");
  1320.     else
  1321.     OPrint(FormatName(Me()@p_pName) + " has " + what + ".\n");
  1322.     fi;
  1323. corp;
  1324.  
  1325. /*****************************************************************************\
  1326. *                                          *
  1327. *        now some subsubcommands for building rooms              *
  1328. *                                          *
  1329. \*****************************************************************************/
  1330.  
  1331. define tp_build1 g_room CreateGrammar().
  1332.  
  1333. define tp_build1 proc utility bv_room()bool:
  1334.     thing here;
  1335.     string s;
  1336.  
  1337.     here := Here();
  1338.     s := GetTail();
  1339.     if s = "" then
  1340.     Print("Missing room command - "
  1341.           "see builder's library for details.\n");
  1342.     false
  1343.     elif not Mine(here) and (GetThingStatus(here) = ts_readonly or
  1344.     GetThingStatus(here) = ts_wizard and not IsWizard()) and
  1345.     MeCharacter() ~= SysAdmin
  1346.     then
  1347.     Print("The owner of this room has not permitted it.\n");
  1348.     false
  1349.     else
  1350.     Parse(g_room, s) ~= 0
  1351.     fi
  1352. corp;
  1353.  
  1354. VerbTail(g_build, "r", bv_room).
  1355. Synonym(g_build, "r", "room").
  1356.  
  1357. define tp_build proc utility doCreateRoom(int dir, kind; string s)void:
  1358.     thing room;
  1359.  
  1360.     room := CreateThing(
  1361.     case kind
  1362.     incase 0:
  1363.         r_indoors
  1364.     incase 1:
  1365.         r_outdoors
  1366.     incase 2:
  1367.         r_forest
  1368.     incase 3:
  1369.         r_field
  1370.     incase 4:
  1371.         r_path
  1372.     incase 5:
  1373.         r_road
  1374.     incase 6:
  1375.         r_sidewalk
  1376.     incase 7:
  1377.         r_park
  1378.     incase 8:
  1379.         r_tunnel
  1380.     default:
  1381.         nil
  1382.     esac);
  1383.     room@p_rName := s;
  1384.     room@p_rContents := CreateThingList();
  1385.     SetThingStatus(room, ts_readonly);
  1386.     Connect(Here(), room, dir);
  1387.     if Here()@p_rPlayPen then
  1388.     room@p_rPlayPen := true;
  1389.     fi;
  1390.     Print("New room created and linked.\n");
  1391.     changeDone("created a new room");
  1392. corp;
  1393.  
  1394. define tp_build1 proc utility brv_new()bool:
  1395.     string s, error;
  1396.     int dir, kind;
  1397.  
  1398.     error := "Use is: @room new <dir> <kind> <room-name>\n";
  1399.     s := GetWord();
  1400.     if s = "" then
  1401.     Print(error);
  1402.     false
  1403.     else
  1404.     dir := DirMatch(s);
  1405.     if dir = -1 then
  1406.         Print(error);
  1407.         false
  1408.     else
  1409.         s := GetWord();
  1410.         kind := MatchName("indoors.outdoors.forest.field.path.road."
  1411.                   "sidewalk.park.tunnel", s);
  1412.         if kind = -1 then
  1413.         Print("Unknown room kind. Known kinds are: indoors, outdoors, "
  1414.             "forest, field, path, road, sidewalk, park, tunnel\n");
  1415.         false
  1416.         else
  1417.         s := Strip(GetTail());
  1418.         if s = "" then
  1419.             Print(error);
  1420.             false
  1421.         elif Here()@(DirProp(dir)) ~= nil then
  1422.             Print("That direction is already in use.\n");
  1423.             false
  1424.         else
  1425.             doCreateRoom(dir, kind, s);
  1426.             true
  1427.         fi
  1428.         fi
  1429.     fi
  1430.     fi
  1431. corp;
  1432.  
  1433. VerbTail(g_room, "new", brv_new).
  1434.  
  1435. define tp_build1 proc utility brv_newname()bool:
  1436.     string name;
  1437.  
  1438.     name := GetTail();
  1439.     if name = "" then
  1440.     Print("Use is: @room newname <room-name>\n");
  1441.     false
  1442.     else
  1443.     Here()@p_rName := name;
  1444.     Print("Room renamed.\n");
  1445.     changeDone("renamed this room");
  1446.     true
  1447.     fi
  1448. corp;
  1449.  
  1450. VerbTail(g_room, "newname", brv_newname).
  1451.  
  1452. define tp_build1 proc utility brv_hide(string dirName)bool:
  1453.     int dir;
  1454.     list int exits;
  1455.  
  1456.     dir := DirMatch(dirName);
  1457.     if dir = -1 then
  1458.     Print("Use is: @room hide <dir>\n");
  1459.     false
  1460.     else
  1461.     exits := Here()@p_rExits;
  1462.     if Here()@(DirProp(dir)) = nil then
  1463.         Print("That direction is not in use.\n");
  1464.         false
  1465.     else
  1466.         if FindElement(exits, dir) = -1 then
  1467.         AddTail(exits, dir);
  1468.         Print("Link unhidden.\n");
  1469.         else
  1470.         DelElement(exits, dir);
  1471.         Print("Link hidden.\n");
  1472.         fi;
  1473.         true
  1474.     fi
  1475.     fi
  1476. corp;
  1477.  
  1478. Verb1(g_room, "hide", 0, brv_hide).
  1479.  
  1480. define tp_build1 proc utility brv_same()bool:
  1481.     thing here;
  1482.     string error, s;
  1483.     int dirOld, dirNew;
  1484.  
  1485.     here := Here();
  1486.     error := "Use is: @room same <old-dir> <new-dir>\n";
  1487.     s := GetWord();
  1488.     if s = "" then
  1489.     Print(error);
  1490.     false
  1491.     else
  1492.     dirOld := DirMatch(s);
  1493.     if dirOld = -1 then
  1494.         Print(error);
  1495.         false
  1496.     elif here@(DirProp(dirOld)) = nil then
  1497.         Print("That old direction does not go anywhere.\n");
  1498.         false
  1499.     else
  1500.         s := GetWord();
  1501.         if s = "" or GetWord() ~= "" then
  1502.         Print(error);
  1503.         false
  1504.         else
  1505.         dirNew := DirMatch(s);
  1506.         if dirNew = -1 then
  1507.             Print(error);
  1508.             false
  1509.         elif here@(DirProp(dirNew)) ~= nil then
  1510.             Print("That new direction is already in use.\n");
  1511.             false
  1512.         else
  1513.             UniConnect(here, here@(DirProp(dirOld)), dirNew);
  1514.             Print("Link made.\n");
  1515.             changeDone("made a new link");
  1516.             true
  1517.         fi
  1518.         fi
  1519.     fi
  1520.     fi
  1521. corp;
  1522.  
  1523. VerbTail(g_room, "same", brv_same).
  1524.  
  1525. define tp_build1 proc utility brv_scenery()bool:
  1526.     string s;
  1527.     bool hadOne;
  1528.  
  1529.     hadOne := false;
  1530.     while
  1531.     s := GetWord();
  1532.     s ~= ""
  1533.     do
  1534.     hadOne := true;
  1535.     Scenery(Here(), s);
  1536.     od;
  1537.     if hadOne then
  1538.     Print("New scenery words added.\n");
  1539.     true
  1540.     else
  1541.     Print("Use is: @room scenery <word> ... <word>\n");
  1542.     false
  1543.     fi
  1544. corp;
  1545.  
  1546. VerbTail(g_room, "scenery", brv_scenery).
  1547.  
  1548. define tp_build1 proc utility brv_endNewdesc(string s)void:
  1549.     thing here;
  1550.  
  1551.     here := Here();
  1552.     if Me()@p_pBuilder or here@p_rPlayPen then
  1553.     s := Trim(s);
  1554.     if s = "" then
  1555.         here -- p_rDesc;
  1556.         Print("Room description deleted.\n");
  1557.     else
  1558.         here@p_rDesc := s;
  1559.         Print("Room decorated.\n");
  1560.     fi;
  1561.     changeDone("decorated this room");
  1562.     else
  1563.     Print("Description change cancelled.\n");
  1564.     fi;
  1565. corp;
  1566.  
  1567. define tp_build proc utility brv_newdesc()bool:
  1568.  
  1569.     GetDocument("new room desc> ", "Enter room description", Here()@p_rDesc,
  1570.     brv_endNewdesc, false)
  1571. corp;
  1572.  
  1573. Verb0(g_room, "newdesc", 0, brv_newdesc).
  1574.  
  1575. define tp_build1 proc utility brv_endAdddesc1(string s)void:
  1576.  
  1577.     if Me()@p_pBuilder or Here()@p_rPlayPen then
  1578.     s := Trim(s);
  1579.     if s = "" then
  1580.         Print("Room description not changed.\n");
  1581.     else
  1582.         Here()@p_rDesc := s;
  1583.         Print("Room redecorated.\n");
  1584.         changeDone("redecorated this room");
  1585.     fi;
  1586.     else
  1587.     Print("Description change cancelled.\n");
  1588.     fi;
  1589. corp;
  1590.  
  1591. define tp_build1 proc utility brv_endAdddesc2(string s)void:
  1592.  
  1593.     if Me()@p_pBuilder or Here()@p_rPlayPen then
  1594.     s := Trim(s);
  1595.     if s = "" then
  1596.         Print("Room description not changed.\n");
  1597.     else
  1598.         ExtendDesc(Here(), s);
  1599.         Print("Room redecorated.\n");
  1600.         changeDone("redecorated this room");
  1601.     fi;
  1602.     else
  1603.     Print("Description change cancelled.\n");
  1604.     fi;
  1605. corp;
  1606.  
  1607. define tp_build1 proc utility brv_adddesc()bool:
  1608.  
  1609.     if CanEdit() then
  1610.     GetDocument("add room desc> ", "Edit room description", Here()@p_rDesc,
  1611.         brv_endAdddesc1, false)
  1612.     else
  1613.     GetDocument("add room desc> ", "Edit room description", "",
  1614.         brv_endAdddesc2, false)
  1615.     fi
  1616. corp;
  1617.  
  1618. Verb0(g_room, "adddesc", 0, brv_adddesc).
  1619.  
  1620. define tp_build1 proc utility brv_setdescaction(string name)bool:
  1621.     action a;
  1622.  
  1623.     if name = "" then
  1624.     Print("Use is: @room setdescaction <action-symbol>\n");
  1625.     false
  1626.     else
  1627.     if name == "nil" then
  1628.         Here() -- p_rDescAction;
  1629.         Print("Descaction removed.\n");
  1630.         changeDone("altered something here");
  1631.         true
  1632.     else
  1633.         a := actionNameCheck(name);
  1634.         if a = nil then
  1635.         false
  1636.         else
  1637.         Here()@p_rDescAction := a;
  1638.         Print("Descaction set.\n");
  1639.         changeDone("altered something here");
  1640.         true
  1641.         fi
  1642.     fi
  1643.     fi
  1644. corp;
  1645.  
  1646. Verb1(g_room, "setdescaction", 0, brv_setdescaction).
  1647.  
  1648. define tp_build1 proc utility brv_addspecialaction()bool:
  1649.     string name, command;
  1650.     action a;
  1651.  
  1652.     name := GetWord();
  1653.     command := GetWord();
  1654.     if name = "" or command = "" or GetWord() ~= "" then
  1655.     Print("Use is: @room addspecialaction <action-symbol> <verb-form>\n");
  1656.     false
  1657.     else
  1658.     a := actionNameCheck(name);
  1659.     if a = nil then
  1660.         false
  1661.     else
  1662.         AddSpecialCommand(Here(), command, a);
  1663.         Print("Special command set.\n");
  1664.         changeDone("altered something here");
  1665.         true
  1666.     fi
  1667.     fi
  1668. corp;
  1669.  
  1670. VerbTail(g_room, "addspecialaction", brv_addspecialaction).
  1671.  
  1672. define tp_build1 proc utility brv_subspecialaction()bool:
  1673.     string name, command;
  1674.     action a;
  1675.  
  1676.     name := GetWord();
  1677.     command := GetWord();
  1678.     if name = "" or command = "" or GetWord() ~= "" then
  1679.     Print("Use is: @room subspecialaction <action-symbol> <verb-form>\n");
  1680.     false
  1681.     else
  1682.     a := actionNameCheck(name);
  1683.     if a = nil then
  1684.         false
  1685.     else
  1686.         if RemoveSpecialCommand(Here(), command, a) then
  1687.         Print("Special command set.\n");
  1688.         changeDone("altered something here");
  1689.         true
  1690.         else
  1691.         Print("That special command is not set here.\n");
  1692.         false
  1693.         fi
  1694.     fi
  1695.     fi
  1696. corp;
  1697.  
  1698. VerbTail(g_room, "subspecialaction", brv_subspecialaction).
  1699.  
  1700. define tp_build proc utility doMakeLink(string s; int dir)bool:
  1701.     thing there;
  1702.  
  1703.     there := LookupThing(nil, s);
  1704.     if there = nil then
  1705.     if IsDefined(nil, s) then
  1706.         Print("Name '" + s + "' is not a room.\n");
  1707.     else
  1708.         Print("Name '" + s + "' is not defined.\n");
  1709.     fi;
  1710.     false
  1711.     elif there@p_rName = "" and there@p_rNameAction = nil then
  1712.     Print("Name '" + s + "' is not a room.\n");
  1713.     false
  1714.     elif Here()@p_rPlayPen and not there@p_rPlayPen then
  1715.     Print("Cannot link to non-playpen rooms from playpen rooms\n");
  1716.     false
  1717.     elif not Mine(there) and (GetThingStatus(there) = ts_readonly or
  1718.     GetThingStatus(there) = ts_wizard and not IsWizard()) and
  1719.     MeCharacter() ~= SysAdmin
  1720.     then
  1721.     Print("The owner of that room has not permitted it.\n");
  1722.     false
  1723.     else
  1724.     UniConnect(Here(), there, dir);
  1725.     Print("Link made.\n");
  1726.     changeDone("made a new link");
  1727.     true
  1728.     fi
  1729. corp;
  1730.  
  1731. define tp_build1 proc utility brv_linkto()bool:
  1732.     thing here;
  1733.     string error, s;
  1734.     int dir;
  1735.  
  1736.     error := "Use is: @room linkto <dir> <room-symbol>\n";
  1737.     here := Here();
  1738.     s := GetWord();
  1739.     if s = "" then
  1740.     Print(error);
  1741.     false
  1742.     else
  1743.     dir := DirMatch(s);
  1744.     if dir = -1 then
  1745.         Print(error);
  1746.         false
  1747.     elif here@(DirProp(dir)) ~= nil then
  1748.         Print("That direction is already in use.\n");
  1749.         false
  1750.     else
  1751.         s := GetWord();
  1752.         if s = "" or GetWord() ~= "" then
  1753.         Print(error);
  1754.         false
  1755.         else
  1756.         doMakeLink(s, dir)
  1757.         fi
  1758.     fi
  1759.     fi
  1760. corp;
  1761.  
  1762. VerbTail(g_room, "linkto", brv_linkto).
  1763.  
  1764. define tp_build proc utility brv_unlink(string dirName)bool:
  1765.     int dir;
  1766.     list int exits;
  1767.  
  1768.     dir := DirMatch(dirName);
  1769.     if dir = -1 then
  1770.     Print("Use is: @room unlink <dir>\n");
  1771.     false
  1772.     elif Here()@(DirProp(dir)) = nil then
  1773.     Print("There is no link in that direction from here.\n");
  1774.     false
  1775.     elif dir = D_NORTH and Here() = r_playPen then
  1776.     Print("Only a wizard or apprentice can remove the Playpen's exit.\n");
  1777.     false
  1778.     else
  1779.     Here() -- DirProp(dir);
  1780.     exits := Here()@p_rExits;
  1781.     if exits ~= nil then
  1782.         DelElement(exits, dir);
  1783.     fi;
  1784.     Print("Connection removed.\n");
  1785.     changeDone("removed a link");
  1786.     true
  1787.     fi
  1788. corp;
  1789.  
  1790. Verb1(g_room, "unlink", 0, brv_unlink).
  1791.  
  1792. define tp_build proc utility brv_dark(string s)bool:
  1793.     thing here;
  1794.  
  1795.     here := Here();
  1796.     if not Mine(here) then
  1797.     Print("Can only change the lighting in your own rooms.\n");
  1798.     false
  1799.     else
  1800.     if s = "" then
  1801.         s := "y";
  1802.     fi;
  1803.     if isYes(s) then
  1804.         here@p_rDark := true;
  1805.         Print("This room is now dark.\n");
  1806.         if Me()@p_pHidden then
  1807.         OPrint("The light has gone away.\n");
  1808.         else
  1809.         OPrint(FormatName(Me()@p_pName) + " has removed the light.\n");
  1810.         fi;
  1811.         true
  1812.     elif isNo(s) then
  1813.         here -- p_rDark;
  1814.         Print("This room is now lighted.\n");
  1815.         if Me()@p_pHidden then
  1816.         OPrint("Light has appeared\n");
  1817.         else
  1818.         OPrint(FormatName(Me()@p_pName) + " has created light.\n");
  1819.         fi;
  1820.         true
  1821.     else
  1822.         Print("Use is: @room dark [y|n]\n");
  1823.         false
  1824.     fi
  1825.     fi
  1826. corp;
  1827.  
  1828. Verb1(g_room, "dark", 0, brv_dark).
  1829.  
  1830. define tp_build proc utility brv_lock(string s)bool:
  1831.     thing here;
  1832.  
  1833.     here := Here();
  1834.     if not Mine(here) then
  1835.     Print("Can only lock/unlock your own rooms.\n");
  1836.     false
  1837.     else
  1838.     if s = "" then
  1839.         s := "y";
  1840.     fi;
  1841.     if isYes(s) then
  1842.         here@p_rLocked := true;
  1843.         Print("This room is now locked from public access.\n");
  1844.         true
  1845.     elif isNo(s) then
  1846.         here -- p_rLocked;
  1847.         Print("This room is now available for public access.\n");
  1848.         true
  1849.     else
  1850.         Print("Use is: @room lock [y|n]\n");
  1851.         false
  1852.     fi
  1853.     fi
  1854. corp;
  1855.  
  1856. Verb1(g_room, "lock", 0, brv_lock).
  1857.  
  1858. define tp_build1 proc utility brv_status(string s)bool:
  1859.     string error;
  1860.     thing here;
  1861.  
  1862.     here := Here();
  1863.     if not Mine(here) then
  1864.     Print("Can only change the status on your own rooms.\n");
  1865.     false
  1866.     else
  1867.     error := "Use is: @room status {readonly|wizard|public}\n";
  1868.     if s = "" then
  1869.         Print(error);
  1870.         false
  1871.     else
  1872.         if s == "readonly" then
  1873.         SetThingStatus(here, ts_readonly);
  1874.         Print("This room is now changeable by its owner only.\n");
  1875.         true
  1876.         elif s == "wizard" then
  1877.         SetThingStatus(here, ts_wizard);
  1878.         Print("This room is now changeable by wizards only.\n");
  1879.         true
  1880.         elif s == "public" then
  1881.         SetThingStatus(here, ts_public);
  1882.         Print(
  1883.     "This room is now changeable by wizards, apprentices and builders.\n");
  1884.         true
  1885.         else
  1886.         Print(error);
  1887.         false
  1888.         fi
  1889.     fi
  1890.     fi
  1891. corp;
  1892.  
  1893. Verb1(g_room, "status", 0, brv_status).
  1894.  
  1895. define tp_build1 proc utility brv_endDirDesc(string s)void:
  1896.     thing me, here;
  1897.  
  1898.     me := Me();
  1899.     here := Here();
  1900.     if me@p_pBuilder or here@p_rPlayPen then
  1901.     s := Trim(s);
  1902.     if s = "" then
  1903.         here -- DirDesc(me@p_pActiveDir);
  1904.         Print("Direction description deleted.\n");
  1905.     else
  1906.         here@(DirDesc(me@p_pActiveDir)) := s;
  1907.         Print("Direction decorated.\n");
  1908.     fi;
  1909.     changeDone("done some detailing");
  1910.     else
  1911.     Print("Direction description change cancelled.\n");
  1912.     fi;
  1913.     me -- p_pActiveDir;
  1914. corp;
  1915.  
  1916. define tp_build1 proc utility brv_dirdesc(string where)bool:
  1917.     int dir;
  1918.  
  1919.     dir := DirMatch(where);
  1920.     if dir = -1 then
  1921.     Print("Use is: @room dirdesc <dir>\n");
  1922.     false
  1923.     else
  1924.     Me()@p_pActiveDir := dir;
  1925.     GetDocument("room dirdesc> ", "Enter direction description", "",
  1926.         brv_endDirDesc, false)
  1927.     fi
  1928. corp;
  1929.  
  1930. Verb1(g_room, "dirdesc", 0, brv_dirdesc).
  1931.  
  1932. define tp_build1 proc utility brv_endDirMessage(string s)void:
  1933.     thing me, here;
  1934.  
  1935.     me := Me();
  1936.     here := Here();
  1937.     if me@p_pBuilder or here@p_rPlayPen then
  1938.     s := Trim(s);
  1939.     if s = "" then
  1940.         if me@p_pActiveDir = 100 then
  1941.         here -- p_rNoGoString;
  1942.         Print("NoGo string deleted.\n");
  1943.         else
  1944.         here -- DirMessage(me@p_pActiveDir);
  1945.         Print("Direction message deleted.\n");
  1946.         fi;
  1947.     else
  1948.         if me@p_pActiveDir = 100 then
  1949.         here@p_rNoGoString := s;
  1950.         Print("NoGo message entered.\n");
  1951.         else
  1952.         here@(DirMessage(me@p_pActiveDir)) := s;
  1953.         Print("Direction message entered.\n");
  1954.         fi;
  1955.     fi;
  1956.     changeDone("done some detailing");
  1957.     else
  1958.     Print("Message change cancelled.\n");
  1959.     fi;
  1960.     me -- p_pActiveDir;
  1961. corp;
  1962.  
  1963. define tp_build1 proc utility brv_dirmessage(string where)bool:
  1964.     int dir;
  1965.  
  1966.     if where == "nogo" then
  1967.     dir := 100;
  1968.     else
  1969.     dir := DirMatch(where);
  1970.     fi;
  1971.     if dir = -1 then
  1972.     Print("Use is: @room dirmessage <dir>\n");
  1973.     false
  1974.     else
  1975.     Me()@p_pActiveDir := dir;
  1976.     GetDocument("room dirmessage> ", "Enter direction message", "",
  1977.         brv_endDirMessage, false)
  1978.     fi
  1979. corp;
  1980.  
  1981. Verb1(g_room, "dirmessage", 0, brv_dirmessage).
  1982.  
  1983. define tp_build1 proc utility brv_endDirOMessage(string s)void:
  1984.     thing me, here;
  1985.  
  1986.     me := Me();
  1987.     here := Here();
  1988.     if me@p_pBuilder or here@p_rPlayPen then
  1989.     s := Trim(s);
  1990.     if s = "" then
  1991.         here -- DirOMessage(me@p_pActiveDir);
  1992.         Print("Direction message deleted.\n");
  1993.     else
  1994.         here@(DirOMessage(me@p_pActiveDir)) := s;
  1995.         Print("Direction message entered.\n");
  1996.     fi;
  1997.     changeDone("done some detailing");
  1998.     else
  1999.     Print("Message change cancelled.\n");
  2000.     fi;
  2001.     me -- p_pActiveDir;
  2002. corp;
  2003.  
  2004. define tp_build1 proc utility brv_diromessage(string where)bool:
  2005.     int dir;
  2006.  
  2007.     dir := DirMatch(where);
  2008.     if dir = -1 then
  2009.     Print("Use is: @room diromessage <dir>\n");
  2010.     false
  2011.     else
  2012.     Me()@p_pActiveDir := dir;
  2013.     GetDocument("room diromessage> ", "Enter entering direction message",
  2014.         "", brv_endDirOMessage, false)
  2015.     fi
  2016. corp;
  2017.  
  2018. Verb1(g_room, "diromessage", 0, brv_diromessage).
  2019.  
  2020. define tp_build1 proc utility brv_endDirEMessage(string s)void:
  2021.     thing me, here;
  2022.  
  2023.     me := Me();
  2024.     here := Here();
  2025.     if me@p_pBuilder or here@p_rPlayPen then
  2026.     s := Trim(s);
  2027.     if s = "" then
  2028.         here -- DirEMessage(me@p_pActiveDir);
  2029.         Print("Direction message deleted.\n");
  2030.     else
  2031.         here@(DirEMessage(me@p_pActiveDir)) := s;
  2032.         Print("Direction message entered.\n");
  2033.     fi;
  2034.     changeDone("done some detailing");
  2035.     else
  2036.     Print("Message change cancelled.\n");
  2037.     fi;
  2038.     me -- p_pActiveDir;
  2039. corp;
  2040.  
  2041. define tp_build1 proc utility brv_diremessage(string where)bool:
  2042.     int dir;
  2043.  
  2044.     dir := DirMatch(where);
  2045.     if dir = -1 then
  2046.     Print("Use is: @room diremessage <dir>\n");
  2047.     false
  2048.     else
  2049.     Me()@p_pActiveDir := dir;
  2050.     GetDocument("room diremessage> ", "Enter exiting direction message","",
  2051.         brv_endDirEMessage, false)
  2052.     fi
  2053. corp;
  2054.  
  2055. Verb1(g_room, "diremessage", 0, brv_diremessage).
  2056.  
  2057. define tp_build1 proc utility brv_adddircheck()bool:
  2058.     string dirName, name;
  2059.     int dir;
  2060.     action a;
  2061.  
  2062.     dirName := GetWord();
  2063.     name := GetWord();
  2064.     if dirName == "anyenter" then
  2065.     dir := 100;
  2066.     elif dirName == "anyexit" then
  2067.     dir := 101;
  2068.     else
  2069.     dir := DirMatch(dirName);
  2070.     fi;
  2071.     if dir = -1 or name = "" or GetWord() ~= "" then
  2072.     Print("Use is: @room adddircheck <dir> <action-symbol>\n");
  2073.     false
  2074.     else
  2075.     a := actionNameCheck(name);
  2076.     if a = nil then
  2077.         false
  2078.     else
  2079.         if dir = 100 then
  2080.         AddAnyEnterChecker(Here(), a, false);
  2081.         elif dir = 101 then
  2082.         AddAnyLeaveChecker(Here(), a, false);
  2083.         else
  2084.         AddDirChecker(Here(), dir, a, false);
  2085.         fi;
  2086.         Print("Dircheck entered.\n");
  2087.         changeDone("altered something here");
  2088.         true
  2089.     fi
  2090.     fi
  2091. corp;
  2092.  
  2093. VerbTail(g_room, "adddircheck", brv_adddircheck).
  2094.  
  2095. define tp_build1 proc utility brv_subdircheck()bool:
  2096.     string dirName, name;
  2097.     int dir;
  2098.     action a;
  2099.  
  2100.     dirName := GetWord();
  2101.     name := GetWord();
  2102.     if dirName == "anyenter" then
  2103.     dir := 100;
  2104.     elif dirName == "anyexit" then
  2105.     dir := 101;
  2106.     else
  2107.     dir := DirMatch(dirName);
  2108.     fi;
  2109.     if dir = -1 or name = "" or GetWord() ~= "" then
  2110.     Print("Use is: @room subdircheck <dir> <action-symbol>\n");
  2111.     false
  2112.     else
  2113.     a := actionNameCheck(name);
  2114.     if a = nil then
  2115.         false
  2116.     else
  2117.         if dir = 100 then
  2118.         DelAnyEnterChecker(Here(), a);
  2119.         elif dir = 101 then
  2120.         DelAnyLeaveChecker(Here(), a);
  2121.         else
  2122.         DelDirChecker(Here(), dir, a);
  2123.         fi;
  2124.         Print("Dircheck removed.\n");
  2125.         changeDone("altered something here");
  2126.         true
  2127.     fi
  2128.     fi
  2129. corp;
  2130.  
  2131. VerbTail(g_room, "subdircheck", brv_subdircheck).
  2132.  
  2133. /* need to steal a couple of private definitions */
  2134. use tp_base
  2135.  
  2136. define tp_build1 proc utility brv_showdirchecks(string dirName)bool:
  2137.     list action la;
  2138.     action a;
  2139.     int count, dir, i;
  2140.     string procName;
  2141.  
  2142.     if dirName == "anyenter" then
  2143.     dir := 100;
  2144.     elif dirName == "anyexit" then
  2145.     dir := 101;
  2146.     else
  2147.     dir := DirMatch(dirName);
  2148.     fi;
  2149.     if dir = -1 then
  2150.     Print("Use is: @room showdirchecks <dir>\n");
  2151.     false
  2152.     else
  2153.     if dir = 100 then
  2154.         la := Here()@p_rAnyEnterChecks;
  2155.     elif dir = 101 then
  2156.         la := Here()@p_rAnyLeaveChecks;
  2157.     else
  2158.         la := Here()@(DirChecks(dir));
  2159.     fi;
  2160.     if la = nil then
  2161.         Print("There are no checkers for that direction here.\n");
  2162.     else
  2163.         count := Count(la);
  2164.         i := 0;
  2165.         while i ~= count do
  2166.         Print("Checker ");
  2167.         IPrint(i);
  2168.         Print(":");
  2169.         procName := FindActionSymbol(nil, la[i]);
  2170.         if procName ~= "" then
  2171.             Print(" " + procName + "\n");
  2172.         else
  2173.             Print("\n");
  2174.             PrintAction(la[i]);
  2175.         fi;
  2176.         i := i + 1;
  2177.         od;
  2178.     fi;
  2179.     true
  2180.     fi
  2181. corp;
  2182.  
  2183. unuse tp_base
  2184.  
  2185. Verb1(g_room, "showdirchecks", 0, brv_showdirchecks).
  2186.  
  2187. define tp_build1 proc utility brv_checker()bool:
  2188.     string tableName, name;
  2189.     table theTable;
  2190.  
  2191.     tableName := GetWord();
  2192.     name := GetWord();
  2193.     if tableName = "" or name = "" or GetWord() ~= "" then
  2194.     Print("Use is: @room checker <table> <action-symbol>\n");
  2195.     false
  2196.     else
  2197.     theTable := findTable(tableName, false);
  2198.     if theTable = nil then
  2199.         false
  2200.     elif IsDefined(theTable, name) then
  2201.         Print("'" + name + "' is already defined.\n");
  2202.         false
  2203.     else
  2204.         Me()@p_pCodeKind := ck_roomChecker;
  2205.         getAction(theTable, name)
  2206.     fi
  2207.     fi
  2208. corp;
  2209.  
  2210. VerbTail(g_room, "checker", brv_checker).
  2211.  
  2212. define tp_build1 proc utility brv_descaction()bool:
  2213.     string tableName, name;
  2214.     table theTable;
  2215.  
  2216.     tableName := GetWord();
  2217.     name := GetWord();
  2218.     if tableName = "" or name = "" or GetWord() ~= "" then
  2219.     Print("Use is: @room descaction <table> <action-symbol>\n");
  2220.     false
  2221.     else
  2222.     theTable := findTable(tableName, false);
  2223.     if theTable = nil then
  2224.         false
  2225.     elif IsDefined(theTable, name) then
  2226.         Print("'" + name + "' is already defined.\n");
  2227.         false
  2228.     else
  2229.         Me()@p_pCodeKind := ck_roomDesc;
  2230.         getAction(theTable, name)
  2231.     fi
  2232.     fi
  2233. corp;
  2234.  
  2235. VerbTail(g_room, "descaction", brv_descaction).
  2236.  
  2237. define tp_build1 proc utility brv_specialaction()bool:
  2238.     string tableName, name;
  2239.     table theTable;
  2240.  
  2241.     tableName := GetWord();
  2242.     name := GetWord();
  2243.     if tableName = "" or name = "" or GetWord() ~= "" then
  2244.     Print("Use is: @room specialaction <table> <action-symbol>\n");
  2245.     false
  2246.     else
  2247.     theTable := findTable(tableName, false);
  2248.     if theTable = nil then
  2249.         false
  2250.     elif IsDefined(theTable, name) then
  2251.         Print("'" + name + "' is already defined.\n");
  2252.         false
  2253.     else
  2254.         Me()@p_pCodeKind := ck_roomVoid;
  2255.         getAction(theTable, name)
  2256.     fi
  2257.     fi
  2258. corp;
  2259.  
  2260. VerbTail(g_room, "specialaction", brv_specialaction).
  2261.  
  2262. define tp_build proc utility brv_makebank()bool:
  2263.     thing here;
  2264.  
  2265.     here := Here();
  2266.     if not Mine(here) then
  2267.     Print("Can only make your own rooms into banks.\n");
  2268.     false
  2269.     elif IsBank(here) then
  2270.     if UnmakeBank(here) = succeed then
  2271.         Print("This room is no longer a bank.\n");
  2272.         true
  2273.     else
  2274.         Print("Bank cannot be unmade - it has accounts.\n");
  2275.         false
  2276.     fi
  2277.     else
  2278.     MakeBank(here);
  2279.     Print("This room is now a bank.\n");
  2280.     true
  2281.     fi
  2282. corp;
  2283.  
  2284. Verb0(g_room, "makebank", 0, brv_makebank).
  2285.  
  2286. define tp_build proc utility brv_makestore()bool:
  2287.     thing here;
  2288.  
  2289.     here := Here();
  2290.     if not Mine(here) then
  2291.     Print("Can only make your own rooms into stores.\n");
  2292.     false
  2293.     else
  2294.     if IsStore(here) then
  2295.         UnmakeStore(here);
  2296.         Print("This room is no longer a store.\n");
  2297.         false
  2298.     else
  2299.         MakeStore(here);
  2300.         Print("This room is now a store.\n");
  2301.         true
  2302.     fi
  2303.     fi
  2304. corp;
  2305.  
  2306. Verb0(g_room, "makestore", 0, brv_makestore).
  2307.  
  2308. define tp_build1 proc utility brv_addforsale()bool:
  2309.     string symbol;
  2310.     int price;
  2311.     thing here, th;
  2312.  
  2313.     here := Here();
  2314.     if not Mine(here) then
  2315.     Print("Can only modify your own stores.\n");
  2316.     false
  2317.     elif here@p_rBuyAction ~= StoreBuy then
  2318.     Print("This room is not a store.\n");
  2319.     false
  2320.     else
  2321.     symbol := GetWord();
  2322.     price := StringToPosInt(GetWord());
  2323.     if symbol = "" or price <= 0 or GetWord() ~= "" then
  2324.         Print("Use is: @room addforsale <object-symbol> <price>\n");
  2325.         false
  2326.     else
  2327.         th := objNameCheck(symbol);
  2328.         if th ~= nil then
  2329.         AddObjectForSale(here, th, price, nil);
  2330.         Print(FormatName(th@p_oName) + " is now for sale here.\n");
  2331.         true
  2332.         else
  2333.         false
  2334.         fi
  2335.     fi
  2336.     fi
  2337. corp;
  2338.  
  2339. VerbTail(g_room, "addforsale", brv_addforsale).
  2340.  
  2341. define tp_build1 proc utility brv_subforsale()bool:
  2342.     string symbol;
  2343.     thing here, th;
  2344.  
  2345.     here := Here();
  2346.     if not Mine(here) then
  2347.     Print("Can only modify your own stores.\n");
  2348.     false
  2349.     elif here@p_rBuyAction ~= StoreBuy then
  2350.     Print("This room is not a store.\n");
  2351.     false
  2352.     else
  2353.     symbol := GetWord();
  2354.     if symbol = "" or GetWord() ~= "" then
  2355.         Print("Use is: @room subforsale <object-symbol>\n");
  2356.         false
  2357.     else
  2358.         th := objNameCheck(symbol);
  2359.         if th ~= nil then
  2360.         if SubObjectForSale(here, th) then
  2361.             Print(FormatName(th@p_oName) +
  2362.             " is no longer for sale here.\n");
  2363.             true
  2364.         else
  2365.             Print(FormatName(th@p_oName) + " is not for sale here.\n");
  2366.             false
  2367.         fi
  2368.         else
  2369.         false
  2370.         fi
  2371.     fi
  2372.     fi
  2373. corp;
  2374.  
  2375. VerbTail(g_room, "subforsale", brv_subforsale).
  2376.  
  2377. /*****************************************************************************\
  2378. *                                          *
  2379. *        now some subsubcommands for building objects              *
  2380. *                                          *
  2381. \*****************************************************************************/
  2382.  
  2383. define tp_build1 g_object CreateGrammar().
  2384.  
  2385. define tp_build1 proc utility bv_object()bool:
  2386.     string s;
  2387.  
  2388.     s := GetTail();
  2389.     if s = "" then
  2390.     Print("Missing object command - "
  2391.           "see builder's library for details.\n");
  2392.     true
  2393.     else
  2394.     Parse(g_object, s) ~= 0
  2395.     fi
  2396. corp;
  2397.  
  2398. VerbTail(g_build, "o", bv_object).
  2399. Synonym(g_build, "o", "object").
  2400.  
  2401. define tp_build proc utility createNewObject(string name; table theTable;
  2402.     string symbol)bool:
  2403.     thing me, th;
  2404.  
  2405.     me := Me();
  2406.     if Count(me@p_pCarrying) >= MAX_CARRY then
  2407.     Print("You can't carry anything else.\n");
  2408.     false
  2409.     else
  2410.     th := CreateThing(nil);
  2411.     th@p_oName := name;
  2412.     th@p_oHome := Here();
  2413.     th@p_oCarryer := me;
  2414.     th@p_oCreator := me;
  2415.     if Here()@p_rPlayPen then
  2416.         th@p_rPlayPen := true;
  2417.     fi;
  2418.     SetThingStatus(th, ts_public);
  2419.     GiveThing(th, SysAdmin);
  2420.     AddTail(me@p_pCarrying, th);
  2421.     if DefineThing(theTable, symbol, th) then
  2422.         Print("Object created - you are carrying it.\n");
  2423.         changeDone("created something");
  2424.     fi;
  2425.     true
  2426.     fi
  2427. corp;
  2428.  
  2429. define tp_build1 proc utility bov_new()bool:
  2430.     string tableName, symbol, name;
  2431.     table theTable;
  2432.     thing me, th;
  2433.  
  2434.     tableName := GetWord();
  2435.     symbol := GetWord();
  2436.     name := GetWord();
  2437.     if tableName = "" or symbol = "" or name = "" or GetWord() ~= "" then
  2438.     Print(
  2439.        "Use is: @object new <table> <object-symbol> \"noun[;adj,...,adj]\"\n");
  2440.     false
  2441.     else
  2442.     theTable := findTable(tableName, false);
  2443.     if theTable = nil then
  2444.         false
  2445.     elif IsDefined(theTable, symbol) then
  2446.         Print("'" + symbol + "' is already defined.\n");
  2447.         false
  2448.     else
  2449.         createNewObject(name, theTable, symbol)
  2450.     fi
  2451.     fi
  2452. corp;
  2453.  
  2454. VerbTail(g_object, "new", bov_new).
  2455.  
  2456. define tp_build1 proc utility bov_newname()bool:
  2457.     string symbol, newName;
  2458.     thing th;
  2459.  
  2460.     symbol := GetWord();
  2461.     newName := GetWord();
  2462.     if symbol = "" or newName = "" or GetWord() ~= "" then
  2463.     Print(
  2464.        "Use is: @object newname <object-symbol> \"noun[;adj,...,adj]\"\n");
  2465.     false
  2466.     else
  2467.     th := objNameCheck(symbol);
  2468.     if th ~= nil then
  2469.         th@p_oName := newName;
  2470.         Print("Your object '" + symbol + "' will now be seen as '" +
  2471.           FormatName(newName) + "'.\n");
  2472.         true
  2473.     else
  2474.         false
  2475.     fi
  2476.     fi
  2477. corp;
  2478.  
  2479. VerbTail(g_object, "newname", bov_newname).
  2480. Synonym(g_object, "newname", "name").
  2481.  
  2482. define tp_build1 proc utility bov_endNewdesc(string s)void:
  2483.     thing me;
  2484.  
  2485.     me := Me();
  2486.     s := Trim(s);
  2487.     if s = "" then
  2488.     me@p_pActiveThing -- p_oDesc;
  2489.     Print("Object description deleted.\n");
  2490.     else
  2491.     me@p_pActiveThing@p_oDesc := s;
  2492.     Print("Object description entered.\n");
  2493.     fi;
  2494.     me -- p_pActiveThing;
  2495. corp;
  2496.  
  2497. define tp_build proc utility doObjectDesc(thing th)bool:
  2498.  
  2499.     Me()@p_pActiveThing := th;
  2500.     GetDocument("new object desc> ", "Enter new description",
  2501.     th@p_oDesc, bov_endNewdesc, false)
  2502. corp;
  2503.  
  2504. define tp_build1 proc utility bov_newdesc(string symbol)bool:
  2505.     thing th;
  2506.  
  2507.     if symbol = "" then
  2508.     Print("Use is: @object newdesc <object-symbol>\n");
  2509.     false
  2510.     else
  2511.     th := objNameCheck(symbol);
  2512.     if th ~= nil then
  2513.         doObjectDesc(th)
  2514.     else
  2515.         false
  2516.     fi
  2517.     fi
  2518. corp;
  2519.  
  2520. Verb1(g_object, "newdesc", 0, bov_newdesc).
  2521. Synonym(g_object, "newdesc", "desc").
  2522.  
  2523. define tp_build1 proc utility bov_endReadstring(string s)void:
  2524.     thing me;
  2525.  
  2526.     me := Me();
  2527.     s := Trim(s);
  2528.     if s = "" then
  2529.     me@p_pActiveThing -- p_oReadString;
  2530.     Print("Object readstring deleted.\n");
  2531.     else
  2532.     me@p_pActiveThing@p_oReadString := s;
  2533.     Print("Object readstring entered.\n");
  2534.     fi;
  2535.     me -- p_pActiveThing;
  2536. corp;
  2537.  
  2538. define tp_build proc utility doObjectRead(thing th)bool:
  2539.  
  2540.     Me()@p_pActiveThing := th;
  2541.     GetDocument("new object readstring> ", "Enter new readstring",
  2542.     th@p_oReadString, bov_endReadstring, false)
  2543. corp;
  2544.  
  2545. define tp_build1 proc utility bov_readstring(string symbol)bool:
  2546.     thing th;
  2547.  
  2548.     if symbol = "" then
  2549.     Print("Use is: @object readstring <object-symbol>\n");
  2550.     false
  2551.     else
  2552.     th := objNameCheck(symbol);
  2553.     if th ~= nil then
  2554.         doObjectRead(th)
  2555.     else
  2556.         false
  2557.     fi
  2558.     fi
  2559. corp;
  2560.  
  2561. Verb1(g_object, "readstring", 0, bov_readstring).
  2562.  
  2563. define tp_build1 proc utility bov_setdescaction()bool:
  2564.     string thingName, name;
  2565.     thing th;
  2566.     action a;
  2567.  
  2568.     thingName := GetWord();
  2569.     name := GetWord();
  2570.     if thingName = "" or name = "" or GetWord() ~= "" then
  2571.     Print(
  2572.         "Use is: @object setdescaction <object-symbol> <action-symbol>\n");
  2573.     false
  2574.     else
  2575.     th := objNameCheck(thingName);
  2576.     if th ~= nil then
  2577.         if name == "nil" then
  2578.         th -- p_oDescAction;
  2579.         Print("Descaction removed.\n");
  2580.         true
  2581.         else
  2582.         a := actionNameCheck(name);
  2583.         if a = nil then
  2584.             false
  2585.         else
  2586.             th@p_oDescAction := a;
  2587.             Print("Descaction set.\n");
  2588.             true
  2589.         fi
  2590.         fi
  2591.     else
  2592.         false
  2593.     fi
  2594.     fi
  2595. corp;
  2596.  
  2597. VerbTail(g_object, "setdescaction", bov_setdescaction).
  2598.  
  2599. define tp_build1 proc utility bov_setreadaction()bool:
  2600.     string thingName, name;
  2601.     thing th;
  2602.     action a;
  2603.  
  2604.     thingName := GetWord();
  2605.     name := GetWord();
  2606.     if thingName = "" or name = "" or GetWord() ~= "" then
  2607.     Print(
  2608.         "Use is: @object setreadaction <object-symbol> <action-symbol>\n");
  2609.     false
  2610.     else
  2611.     th := objNameCheck(thingName);
  2612.     if th ~= nil then
  2613.         if name == "nil" then
  2614.         th -- p_oReadAction;
  2615.         Print("Readaction removed.\n");
  2616.         true
  2617.         else
  2618.         a := actionNameCheck(name);
  2619.         if a = nil then
  2620.             false
  2621.         else
  2622.             th@p_oReadAction := a;
  2623.             Print("Readaction set.\n");
  2624.             true
  2625.         fi
  2626.         fi
  2627.     else
  2628.         false
  2629.     fi
  2630.     fi
  2631. corp;
  2632.  
  2633. VerbTail(g_object, "setreadaction", bov_setreadaction).
  2634.  
  2635. define tp_build1 proc utility bov_setactword()bool:
  2636.     string symbol, word;
  2637.     thing th;
  2638.  
  2639.     symbol := GetWord();
  2640.     word := GetWord();
  2641.     if symbol = "" or word = "" or GetWord() ~= "" then
  2642.     Print(
  2643.       "Use is: @object setactword <object-symbol> \"word,synonym,...\"\n");
  2644.     false
  2645.     else
  2646.     th := objNameCheck(symbol);
  2647.     if th ~= nil then
  2648.         th@p_oActWord := word;
  2649.         Print("Your object '" + symbol + AAn("' will now have", word) +
  2650.           " action.\n");
  2651.         true
  2652.     else
  2653.         false
  2654.     fi
  2655.     fi
  2656. corp;
  2657.  
  2658. VerbTail(g_object, "setactword", bov_setactword).
  2659.  
  2660. define tp_build1 proc utility bov_endSetActString(string s)void:
  2661.     thing me;
  2662.  
  2663.     me := Me();
  2664.     s := Trim(s);
  2665.     if s = "" then
  2666.     me@ p_pActiveThing -- p_oActString;
  2667.     Print("Object actstring deleted.\n");
  2668.     else
  2669.     me@p_pActiveThing@p_oActString := s;
  2670.     Print("Object actstring entered.\n");
  2671.     fi;
  2672.     me -- p_pActiveThing;
  2673. corp;
  2674.  
  2675. define tp_build proc enterActString(thing th)bool:
  2676.  
  2677.     Me()@p_pActiveThing := th;
  2678.     GetDocument("action string> ", "Enter action string",
  2679.     th@p_oActString, bov_endSetActString, false)
  2680. corp;
  2681.  
  2682. define tp_build1 proc utility bov_setactstring(string symbol)bool:
  2683.     thing th;
  2684.  
  2685.     if symbol = "" then
  2686.     Print("Use is: @object setactstring <object-symbol>\n");
  2687.     false
  2688.     else
  2689.     th := objNameCheck(symbol);
  2690.     if th ~= nil then
  2691.         enterActString(th)
  2692.     else
  2693.         false
  2694.     fi
  2695.     fi
  2696. corp;
  2697.  
  2698. Verb1(g_object, "setactstring", 0, bov_setactstring).
  2699.  
  2700. define tp_build1 proc utility bov_setactaction()bool:
  2701.     string thingName, name;
  2702.     thing th;
  2703.     action a;
  2704.  
  2705.     thingName := GetWord();
  2706.     name := GetWord();
  2707.     if thingName = "" or name = "" or GetWord() ~= "" then
  2708.     Print(
  2709.         "Use is: @object setactaction <object-symbol> <action-symbol>\n");
  2710.     false
  2711.     else
  2712.     th := objNameCheck(thingName);
  2713.     if th ~= nil then
  2714.         if name == "nil" then
  2715.         th -- p_oActAction;
  2716.         Print("Actaction removed.\n");
  2717.         true
  2718.         else
  2719.         a := actionNameCheck(name);
  2720.         if a = nil then
  2721.             false
  2722.         else
  2723.             th@p_oActAction := a;
  2724.             Print("Actaction set.\n");
  2725.             true
  2726.         fi
  2727.         fi
  2728.     else
  2729.         false
  2730.     fi
  2731.     fi
  2732. corp;
  2733.  
  2734. VerbTail(g_object, "setactaction", bov_setactaction).
  2735.  
  2736. define tp_build1 proc utility bov_gettable()bool:
  2737.     string errorMessage, symbol, yesNo;
  2738.     thing th;
  2739.  
  2740.     errorMessage := "Use is: @object gettable <object-symbol> [yes|no]\n";
  2741.     symbol := GetWord();
  2742.     if symbol = "" then
  2743.     Print(errorMessage);
  2744.     false
  2745.     else
  2746.     th := objNameCheck(symbol);
  2747.     if th ~= nil then
  2748.         yesNo := GetWord();
  2749.         if yesNo = "" then
  2750.         yesNo := "y";
  2751.         fi;
  2752.         if GetWord() ~= "" then
  2753.         Print(errorMessage);
  2754.         false
  2755.         else
  2756.         if isYes(yesNo) then
  2757.             th -- p_oNotGettable;
  2758.             Print(symbol + " marked as gettable.\n");
  2759.             true
  2760.         elif isNo(yesNo) then
  2761.             th@p_oNotGettable := true;
  2762.             Print(symbol + " marked as not gettable.\n");
  2763.             true
  2764.         else
  2765.             Print(errorMessage);
  2766.             false
  2767.         fi
  2768.         fi
  2769.     else
  2770.         false
  2771.     fi
  2772.     fi
  2773. corp;
  2774.  
  2775. VerbTail(g_object, "gettable", bov_gettable).
  2776.  
  2777. define tp_build1 proc utility bov_islight()bool:
  2778.     string errorMessage, symbol, yesNo;
  2779.     thing th;
  2780.  
  2781.     errorMessage := "Use is: @object islight <object-symbol> [yes|no]\n";
  2782.     symbol := GetWord();
  2783.     if symbol = "" then
  2784.     Print(errorMessage);
  2785.     false
  2786.     else
  2787.     th := objNameCheck(symbol);
  2788.     if th ~= nil then
  2789.         yesNo := GetWord();
  2790.         if yesNo = "" then
  2791.         yesNo := "y";
  2792.         fi;
  2793.         if GetWord() ~= "" then
  2794.         Print(errorMessage);
  2795.         false
  2796.         else
  2797.         if isYes(yesNo) then
  2798.             th@p_oLight := true;
  2799.             Print(symbol + " marked as emitting light.\n");
  2800.             true
  2801.         elif isNo(yesNo) then
  2802.             th -- p_oLight;
  2803.             Print(symbol + " marked as not emitting light.\n");
  2804.             true
  2805.         else
  2806.             Print(errorMessage);
  2807.             false
  2808.         fi
  2809.         fi
  2810.     else
  2811.         false
  2812.     fi
  2813.     fi
  2814. corp;
  2815.  
  2816. VerbTail(g_object, "islight", bov_islight).
  2817. Synonym(g_object, "islight", "light").
  2818.  
  2819. define tp_build1 proc utility bov_invisible()bool:
  2820.     string errorMessage, symbol, yesNo;
  2821.     thing th;
  2822.  
  2823.     errorMessage := "Use is: @object invisible <object-symbol> [yes|no]\n";
  2824.     symbol := GetWord();
  2825.     if symbol = "" then
  2826.     Print(errorMessage);
  2827.     false
  2828.     else
  2829.     th := objNameCheck(symbol);
  2830.     if th ~= nil then
  2831.         yesNo := GetWord();
  2832.         if yesNo = "" then
  2833.         yesNo := "y";
  2834.         fi;
  2835.         if GetWord() ~= "" then
  2836.         Print(errorMessage);
  2837.         false
  2838.         else
  2839.         if isYes(yesNo) then
  2840.             th@p_oInvisible := true;
  2841.             Print(symbol + " marked as invisible.\n");
  2842.             true
  2843.         elif isNo(yesNo) then
  2844.             th -- p_oInvisible;
  2845.             Print(symbol + " marked as not invisible.\n");
  2846.             true
  2847.         else
  2848.             Print(errorMessage);
  2849.             false
  2850.         fi
  2851.         fi
  2852.     else
  2853.         false
  2854.     fi
  2855.     fi
  2856. corp;
  2857.  
  2858. VerbTail(g_object, "invisible", bov_invisible).
  2859.  
  2860. define tp_build1 proc utility bov_container()bool:
  2861.     string symbol, count;
  2862.     thing th;
  2863.     int n;
  2864.  
  2865.     symbol := GetWord();
  2866.     count := GetWord();
  2867.     n := StringToPosInt(count);
  2868.     if symbol = "" or n < 0 or GetWord() ~= "" then
  2869.     Print("Use is @object container <object-symbol> <count>\n");
  2870.     false
  2871.     else
  2872.     th := objNameCheck(symbol);
  2873.     if th ~= nil then
  2874.         if n = 0 then
  2875.         th -- p_oContents;
  2876.         th -- p_oCapacity;
  2877.         Print(symbol + " marked as no longer a container.\n");
  2878.         else
  2879.         th@p_oContents := CreateThingList();
  2880.         th@p_oCapacity := n;
  2881.         Print(symbol + " marked with capacity " + IntToString(n) +
  2882.             ".\n");
  2883.         fi;
  2884.         true
  2885.     else
  2886.         false
  2887.     fi
  2888.     fi
  2889. corp;
  2890.  
  2891. VerbTail(g_object, "container", bov_container).
  2892.  
  2893. define tp_build1 proc utility bov_position()bool:
  2894.     thing me, th;
  2895.     string name, count, verb;
  2896.     int n, which;
  2897.  
  2898.     name := GetWord();
  2899.     count := GetWord();
  2900.     verb := Verb();
  2901.     n := StringToPosInt(count);
  2902.     if name = "" or n < 0 or GetWord() ~= "" then
  2903.     Print("Use is @object " + verb + " <object-symbol> <count>\n");
  2904.     false
  2905.     else
  2906.     th := objNameCheck(name);
  2907.     if th ~= nil then
  2908.         which := MatchName("sitin.siton.liein.lieon", verb);
  2909.         if n = 0 then
  2910.         Print("No-one can now '" + verb + "' '" + name + "'\n");
  2911.         case which
  2912.         incase 0:
  2913.             th -- p_oCanSitIn;
  2914.         incase 1:
  2915.             th -- p_oCanSitOn;
  2916.         incase 2:
  2917.             th -- p_oCanLieIn;
  2918.         incase 3:
  2919.             th -- p_oCanLieOn;
  2920.         esac;
  2921.         else
  2922.         Print(IntToString(n) + " can now '" + verb + "' '" + name +
  2923.             "'\n");
  2924.         n := n + 1;
  2925.         case which
  2926.         incase 0:
  2927.             th@p_oCanSitIn := n;
  2928.         incase 1:
  2929.             th@p_oCanSitOn := n;
  2930.         incase 2:
  2931.             th@p_oCanLieIn := n;
  2932.         incase 3:
  2933.             th@p_oCanLieOn := n;
  2934.         esac;
  2935.         fi;
  2936.         true
  2937.     else
  2938.         false
  2939.     fi
  2940.     fi
  2941. corp;
  2942.  
  2943. VerbTail(g_object, "sitin", bov_position).
  2944. VerbTail(g_object, "siton", bov_position).
  2945. VerbTail(g_object, "liein", bov_position).
  2946. VerbTail(g_object, "lieon", bov_position).
  2947.  
  2948. /* this is NOT utility, so that we are SysAdmin and can do the ClearThing */
  2949.  
  2950. define tp_build1 proc localZapObject(thing th)void:
  2951.     ClearThing(th);
  2952. corp;
  2953.  
  2954. define tp_build1 proc utility bov_destroy()bool:
  2955.     string tableName, symbol;
  2956.     table tb;
  2957.     thing me, th;
  2958.  
  2959.     tableName := GetWord();
  2960.     symbol := GetWord();
  2961.     if tableName = "" or symbol = "" or GetWord() ~= "" then
  2962.     Print("Use is: @object destroy <table> <object-symbol>\n");
  2963.     false
  2964.     else
  2965.     tb := findTable(tableName, true);
  2966.     if tb = nil then
  2967.         false
  2968.     else
  2969.         th := objNameCheck(symbol);
  2970.         if th ~= nil then
  2971.         me := Me();
  2972.         if FindElement(me@p_pCarrying, th) < 0 then
  2973.             Print("You are not carrying '" + symbol + "'.\n");
  2974.             false
  2975.         elif th@p_oContents ~= nil and Count(th@p_oContents) ~= 0 then
  2976.             Print("The " + symbol + " is not empty.\n");
  2977.             false
  2978.         else
  2979.             localZapObject(th);
  2980.             if DeleteSymbol(tb, symbol) then
  2981.             DelElement(me@p_pCarrying, th);
  2982.             Print("It should now be gone!\n");
  2983.             changeDone("destroyed something");
  2984.             true
  2985.             else
  2986.             false
  2987.             fi
  2988.         fi
  2989.         else
  2990.         false
  2991.         fi
  2992.     fi
  2993.     fi
  2994. corp;
  2995.  
  2996. VerbTail(g_object, "destroy", bov_destroy).
  2997.  
  2998. define tp_build1 proc utility bov_checker()bool:
  2999.     string tableName, name;
  3000.     table theTable;
  3001.  
  3002.     tableName := GetWord();
  3003.     name := GetWord();
  3004.     if tableName = "" or name = "" or GetWord() ~= "" then
  3005.     Print("Use is: @object checker <table> <action-symbol>\n");
  3006.     false
  3007.     else
  3008.     theTable := findTable(tableName, false);
  3009.     if theTable = nil then
  3010.         false
  3011.     elif IsDefined(theTable, name) then
  3012.         Print("'" + name + "' is already defined.\n");
  3013.         false
  3014.     else
  3015.         Me()@p_pCodeKind := ck_objectChecker;
  3016.         getAction(theTable, name)
  3017.     fi
  3018.     fi
  3019. corp;
  3020.  
  3021. VerbTail(g_object, "checker", bov_checker).
  3022.  
  3023. define tp_build1 proc utility bov_descaction()bool:
  3024.     string tableName, name;
  3025.     table theTable;
  3026.  
  3027.     tableName := GetWord();
  3028.     name := GetWord();
  3029.     if tableName = "" or name = "" or GetWord() ~= "" then
  3030.     Print("Use is: @object descaction <table> <action-symbol>\n");
  3031.     false
  3032.     else
  3033.     theTable := findTable(tableName, false);
  3034.     if theTable = nil then
  3035.         false
  3036.     elif IsDefined(theTable, name) then
  3037.         Print("'" + name + "' is already defined.\n");
  3038.         false
  3039.     else
  3040.         Me()@p_pCodeKind := ck_objectDesc;
  3041.         getAction(theTable, name)
  3042.     fi
  3043.     fi
  3044. corp;
  3045.  
  3046. VerbTail(g_object, "descaction", bov_descaction).
  3047. Synonym(g_object, "descaction", "readaction").
  3048.  
  3049. define tp_build1 proc utility bov_actaction()bool:
  3050.     string tableName, name;
  3051.     table theTable;
  3052.  
  3053.     tableName := GetWord();
  3054.     name := GetWord();
  3055.     if tableName = "" or name = "" or GetWord() ~= "" then
  3056.     Print("Use is: @object actaction <table> <action-symbol>\n");
  3057.     false
  3058.     else
  3059.     theTable := findTable(tableName, false);
  3060.     if theTable = nil then
  3061.         false
  3062.     elif IsDefined(theTable, name) then
  3063.         Print("'" + name + "' is already defined.\n");
  3064.         false
  3065.     else
  3066.         Me()@p_pCodeKind := ck_objectVoid;
  3067.         getAction(theTable, name)
  3068.     fi
  3069.     fi
  3070. corp;
  3071.  
  3072. VerbTail(g_object, "actaction", bov_actaction).
  3073.  
  3074. define tp_build1 proc utility bov_endVerbString(string s)void:
  3075.     thing me;
  3076.     string verb;
  3077.     property string theProp;
  3078.  
  3079.     me := Me();
  3080.     verb := me@p_pActiveVerb;
  3081.     theProp := GetVerbStringProp(verb);
  3082.     if theProp = nil then
  3083.     Print("Oh-oh! bov_endVerbString can't find prop!\n");
  3084.     else
  3085.     s := Trim(s);
  3086.     if s = "" then
  3087.         me@p_pActiveThing -- GetVerbStringProp(verb);
  3088.         Print("Object " + verb + " string deleted.\n");
  3089.     else
  3090.         me@p_pActiveThing@(GetVerbStringProp(verb)) := s;
  3091.         Print("Object " + verb + " string entered.\n");
  3092.     fi;
  3093.     fi;
  3094.     me -- p_pActiveThing;
  3095.     me -- p_pActiveVerb;
  3096. corp;
  3097.  
  3098. define tp_build proc utility doSetVerbString(string verb; thing th)bool:
  3099.  
  3100.     Me()@p_pActiveVerb := verb;
  3101.     Me()@p_pActiveThing := th;
  3102.     GetDocument(verb + " string> ", "Enter " + verb + " string",
  3103.     th@(GetVerbStringProp(verb)), bov_endVerbString, false)
  3104. corp;
  3105.  
  3106. define tp_build1 proc utility bov_verbstring(string symbol)bool:
  3107.     string verb;
  3108.     thing th;
  3109.  
  3110.     verb := Verb();
  3111.     if symbol = "" then
  3112.     Print("Use is: @object " + verb + " <object-symbol>\n");
  3113.     false
  3114.     else
  3115.     th := objNameCheck(symbol);
  3116.     if th ~= nil then
  3117.         verb := SubString(verb, 0, Length(verb) - 6);
  3118.         doSetVerbString(verb, th)
  3119.     else
  3120.         false
  3121.     fi
  3122.     fi
  3123. corp;
  3124.  
  3125. Verb1(g_object, "playstring", 0, bov_verbstring).
  3126. Verb1(g_object, "erasestring", 0, bov_verbstring).
  3127. Verb1(g_object, "eatstring", 0, bov_verbstring).
  3128. Verb1(g_object, "usestring", 0, bov_verbstring).
  3129. Verb1(g_object, "activatestring", 0, bov_verbstring).
  3130. Verb1(g_object, "deactivatestring", 0, bov_verbstring).
  3131. Synonym(g_object, "deactivatestring", "inactivatestring").
  3132. Verb1(g_object, "lightstring", 0, bov_verbstring).
  3133. Verb1(g_object, "extinguishstring", 0, bov_verbstring).
  3134. Verb1(g_object, "wearstring", 0, bov_verbstring).
  3135. Verb1(g_object, "touchstring", 0, bov_verbstring).
  3136. Verb1(g_object, "smellstring", 0, bov_verbstring).
  3137. Verb1(g_object, "listenstring", 0, bov_verbstring).
  3138. Verb1(g_object, "openstring", 0, bov_verbstring).
  3139. Verb1(g_object, "closestring", 0, bov_verbstring).
  3140. Verb1(g_object, "pushstring", 0, bov_verbstring).
  3141. Verb1(g_object, "pullstring", 0, bov_verbstring).
  3142. Verb1(g_object, "turnstring", 0, bov_verbstring).
  3143. Verb1(g_object, "liftstring", 0, bov_verbstring).
  3144. Verb1(g_object, "lowerstring", 0, bov_verbstring).
  3145. Verb1(g_object, "getstring", 0, bov_verbstring).
  3146. Verb1(g_object, "unlockstring", 0, bov_verbstring).
  3147.  
  3148. define tp_build1 proc utility bov_verbchecker()bool:
  3149.     string verb, objectName, actionName;
  3150.     property action theProp;
  3151.     action a;
  3152.     thing th;
  3153.  
  3154.     verb := Verb();
  3155.     objectName := GetWord();
  3156.     actionName := GetWord();
  3157.     if objectName = "" or actionName = "" or GetWord() ~= "" then
  3158.     Print(
  3159.         "Use is: @object " + verb + " <object-symbol> <action-symbol>\n");
  3160.     false
  3161.     else
  3162.     th := objNameCheck(objectName);
  3163.     if th ~= nil then
  3164.         verb := SubString(verb, 0, Length(verb) - 7);
  3165.         theProp := GetVerbCheckerProp(verb);
  3166.         if theProp = nil then
  3167.         Print("Oh-oh! bov_verbchecker can't find prop!\n");
  3168.         false
  3169.         else
  3170.         if actionName == "nil" then
  3171.             th -- theProp;
  3172.             Print(Capitalize(verb) + "action removed.\n");
  3173.             true
  3174.         else
  3175.             a := actionNameCheck(actionName);
  3176.             if a = nil then
  3177.             false
  3178.             else
  3179.             th@theProp := a;
  3180.             Print(Capitalize(verb) + "action set.\n");
  3181.             true
  3182.             fi
  3183.         fi
  3184.         fi
  3185.     else
  3186.         false
  3187.     fi
  3188.     fi
  3189. corp;
  3190.  
  3191. VerbTail(g_object, "playchecker", bov_verbchecker).
  3192. VerbTail(g_object, "erasechecker", bov_verbchecker).
  3193. VerbTail(g_object, "eatchecker", bov_verbchecker).
  3194. VerbTail(g_object, "usechecker", bov_verbchecker).
  3195. VerbTail(g_object, "activatechecker", bov_verbchecker).
  3196. VerbTail(g_object, "inactivatechecker", bov_verbchecker).
  3197. Synonym(g_object, "inactivatechecker", "deactivatechecker").
  3198. VerbTail(g_object, "lightchecker", bov_verbchecker).
  3199. VerbTail(g_object, "extinguishchecker", bov_verbchecker).
  3200. VerbTail(g_object, "wearchecker", bov_verbchecker).
  3201. VerbTail(g_object, "touchchecker", bov_verbchecker).
  3202. VerbTail(g_object, "smellchecker", bov_verbchecker).
  3203. VerbTail(g_object, "listenchecker", bov_verbchecker).
  3204. VerbTail(g_object, "openchecker", bov_verbchecker).
  3205. VerbTail(g_object, "closechecker", bov_verbchecker).
  3206. VerbTail(g_object, "pushchecker", bov_verbchecker).
  3207. VerbTail(g_object, "pullchecker", bov_verbchecker).
  3208. VerbTail(g_object, "turnchecker", bov_verbchecker).
  3209. VerbTail(g_object, "liftchecker", bov_verbchecker).
  3210. VerbTail(g_object, "lowerchecker", bov_verbchecker).
  3211.  
  3212. unuse tp_build1
  3213.